From e7c89e8fa770beacd1276dc35df0f407441da1cb Mon Sep 17 00:00:00 2001 From: Aneurin Barker Snook Date: Sun, 8 Oct 2023 16:12:06 +0100 Subject: [PATCH] add empty params test --- query_test.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/query_test.go b/query_test.go index 8def6b3..8b2c86b 100644 --- a/query_test.go +++ b/query_test.go @@ -12,15 +12,10 @@ func TestQueryAppend(t *testing.T) { } testCases := []TestCase{ - // Append without parameters + // Initialise empty query { - Input: NewQuery(). - Append("FOR doc IN @@collection"). - Append("FILTER doc.title == @title"). - Append("RETURN doc"), - ExpectedStr: `FOR doc IN @@collection -FILTER doc.title == @title -RETURN doc`, + Input: NewQuery(), + ExpectedStr: "", ExpectedParams: map[string]any{}, }, // Append with parameters @@ -93,6 +88,10 @@ RETURN doc`, t.Errorf("Expected %q, got %q", tc.ExpectedStr, actualStr) } + if tc.Input.Params == nil { + t.Error("Expected empty slice, got nil") + continue + } if len(tc.Input.Params) != len(tc.ExpectedParams) { t.Errorf("Expected %d parameters, got %d", len(tc.ExpectedParams), len(tc.Input.Params)) }