Skip to content

Commit

Permalink
add unit test for archive trace
Browse files Browse the repository at this point in the history
Signed-off-by: Zhang Xin <[email protected]>
  • Loading branch information
rim99 committed Dec 20, 2024
1 parent f0fa4e2 commit 06f4a1a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions cmd/query/app/handler_archive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,27 @@ func TestArchiveTrace_WriteErrors(t *testing.T) {
require.EqualError(t, err, `500 error from server: {"data":null,"total":0,"limit":0,"offset":0,"errors":[{"code":500,"msg":"cannot save\ncannot save"}]}`+"\n")
}, querysvc.QueryServiceOptions{ArchiveSpanWriter: mockWriter})
}

func TestArchiveTrace_BadTimeWindow(t *testing.T) {
testCases := []struct {
name string
query string
}{
{
name: "Bad start time",
query: "start=a",
},
{
name: "Bad end time",
query: "end=b",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
ts := initializeTestServer(t)
var response structuredResponse
err := getJSON(ts.server.URL+"/api/archive/"+mockTraceID.String()+"&"+tc.query, &response)
require.Error(t, err)
})
}
}

0 comments on commit 06f4a1a

Please sign in to comment.