Skip to content

Commit 0f9c232

Browse files
committed
ci: fix trace test case
1 parent f2af6a2 commit 0f9c232

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

dataloader_test.go

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,31 @@ func testTrace(t *testing.T) {
6262
t.Errorf("Expected 11 spans, got %d", len(spans.Snapshots()))
6363
}
6464

65-
if spans.Snapshots()[0].Name() != "dataLoader.Batch" {
66-
t.Errorf("Unexpected span name: %v", spans.Snapshots()[0].Name())
67-
}
68-
69-
if len(spans.Snapshots()[0].Links()) != 10 {
70-
t.Errorf("Expected 10 links, got %d", len(spans.Snapshots()[0].Links()))
65+
haveBatch := false
66+
haveLoad := false
67+
loadCount := 0
68+
for _, s := range spans.Snapshots() {
69+
if s.Name() == "dataLoader.Batch" {
70+
haveBatch = true
71+
if len(s.Links()) != 10 {
72+
t.Errorf("Expected 10 links, got %d", len(s.Links()))
73+
}
74+
}
75+
if s.Name() == "dataLoader.Load" {
76+
loadCount++
77+
haveLoad = true
78+
if len(s.Links()) != 0 {
79+
t.Errorf("Expected 0 link, got %d", len(s.Links()))
80+
}
81+
}
7182
}
7283

73-
if spans.Snapshots()[1].Name() != "dataLoader.Load" {
74-
t.Errorf("Unexpected span name: %v", spans.Snapshots()[0].Name())
84+
if !haveBatch {
85+
t.Errorf("Expected to have a batch span")
7586
}
7687

77-
if len(spans.Snapshots()[1].Links()) != 0 {
78-
t.Errorf("Expected 3 links, got %d", len(spans.Snapshots()[0].Links()))
88+
if !haveLoad {
89+
t.Errorf("Expected to have a load span")
7990
}
8091

8192
exporter.Reset()

0 commit comments

Comments
 (0)