From 06f4a1a36b50db1f3d8aae266a31bdcb524d7e0b Mon Sep 17 00:00:00 2001 From: Zhang Xin Date: Fri, 20 Dec 2024 21:04:38 +0800 Subject: [PATCH] add unit test for archive trace Signed-off-by: Zhang Xin --- cmd/query/app/handler_archive_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/cmd/query/app/handler_archive_test.go b/cmd/query/app/handler_archive_test.go index 87ae3e304b2..ac69a393d15 100644 --- a/cmd/query/app/handler_archive_test.go +++ b/cmd/query/app/handler_archive_test.go @@ -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) + }) + } +}