@@ -62,20 +62,31 @@ func testTrace(t *testing.T) {
62
62
t .Errorf ("Expected 11 spans, got %d" , len (spans .Snapshots ()))
63
63
}
64
64
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
+ }
71
82
}
72
83
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" )
75
86
}
76
87
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" )
79
90
}
80
91
81
92
exporter .Reset ()
0 commit comments