Skip to content

Commit

Permalink
mocktracer and error code fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahkm committed Oct 25, 2024
1 parent 21b44e6 commit 07f6de4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions instrumentation/httptrace/httptrace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ func TestConfiguredErrorStatuses(t *testing.T) {
switch status {
case 0:
assert.Equal(t, "200", spans[i].Tag(ext.HTTPCode))
assert.Nil(t, spans[i].Tag(ext.Error))
assert.Nil(t, spans[i].Tag(ext.ErrorMsg))
case 200, 400:
assert.Equal(t, strconv.Itoa(status), spans[i].Tag(ext.HTTPCode))
assert.Equal(t, fmt.Errorf("%s: %s", strconv.Itoa(status), http.StatusText(status)), spans[i].Tag(ext.Error).(error))
assert.Equal(t, fmt.Sprintf("%s: %s", strconv.Itoa(status), http.StatusText(status)), spans[i].Tag(ext.ErrorMsg))
case 500:
assert.Equal(t, strconv.Itoa(status), spans[i].Tag(ext.HTTPCode))
assert.Nil(t, spans[i].Tag(ext.Error))
assert.Nil(t, spans[i].Tag(ext.ErrorMsg))
}
}
})
Expand All @@ -133,7 +133,7 @@ func TestConfiguredErrorStatuses(t *testing.T) {
spans := mt.FinishedSpans()
require.Len(t, spans, 1)
assert.Equal(t, "0", spans[0].Tag(ext.HTTPCode))
assert.Equal(t, fmt.Errorf("0: %s", http.StatusText(0)), spans[0].Tag(ext.Error).(error))
assert.Equal(t, fmt.Sprintf("0: %s", http.StatusText(0)), spans[0].Tag(ext.ErrorMsg))
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func TestWithInnerFunc(t *testing.T) {
}

func testAssertions(assert *assert.Assertions, now time.Time, testSpan *mocktracer.Span) {
assert.Equal(now, testSpan.StartTime())
assert.Equal(now.Unix(), testSpan.StartTime().Unix())
assert.Equal("my-module-framework.test", testSpan.OperationName())

tags := map[string]interface{}{
Expand All @@ -306,7 +306,7 @@ func testAssertions(assert *assert.Assertions, now time.Time, testSpan *mocktrac
assert.Contains(spanTags, constants.TestSourceStartLine)
assert.Contains(spanTags, constants.TestSourceEndLine)
// make sure the startLine < endLine
assert.Less(spanTags[constants.TestSourceStartLine].(int), spanTags[constants.TestSourceEndLine].(int))
assert.Less(spanTags[constants.TestSourceStartLine].(float64), spanTags[constants.TestSourceEndLine].(float64))

commonAssertions(assert, testSpan)
}

0 comments on commit 07f6de4

Please sign in to comment.