Skip to content

Commit

Permalink
Add test case for OpenTracing SetTag error false/nil
Browse files Browse the repository at this point in the history
  • Loading branch information
cce committed Jun 23, 2020
1 parent 4a107e4 commit 27e4e32
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions v1/ao/opentracing/tracer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,28 @@ func TestSetErrorTags(t *testing.T) {
assert.Equal(t, tc.errorClass, n.Map["ErrorClass"])
assert.Equal(t, tc.errorMsg, n.Map["ErrorMsg"])
}},
{"op", "exit"}: {Edges: g.Edges{{"op", "error"}}, Callback: func(n g.Node) {

}},
{"op", "exit"}: {Edges: g.Edges{{"op", "error"}}, Callback: func(n g.Node) {}},
})
})
}

// test a couple of cases where no error is reported
for _, tc := range []struct{ errorTagVal interface{} }{
{false},
{nil},
} {
r := reporter.SetTestReporter() // set up test reporter
tr := NewTracer()

span := tr.StartSpan("op")
assert.NotNil(t, span)
span.SetTag("error", tc.errorTagVal)
span.Finish()

r.Close(2)
g.AssertGraph(t, r.EventBufs, 2, g.AssertNodeMap{
{"op", "entry"}: {},
{"op", "exit"}: {Edges: g.Edges{{"op", "entry"}}, Callback: func(n g.Node) {}},
})
}
}

0 comments on commit 27e4e32

Please sign in to comment.