From a94c9f93d34ea64cac71b96516fb830a61ccc231 Mon Sep 17 00:00:00 2001 From: Aneurin Barker Snook Date: Sun, 8 Oct 2023 16:04:03 +0100 Subject: [PATCH] fix misuse of break, clean up tests --- params_test.go | 1 + query_test.go | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/params_test.go b/params_test.go index 77df40a..b9c0147 100644 --- a/params_test.go +++ b/params_test.go @@ -31,6 +31,7 @@ func TestReadParams(t *testing.T) { t.Errorf("Expected empty slice, got nil") continue } + if len(params) != len(tc.Output) { t.Errorf("Expected %d parameters", len(tc.Output)) } diff --git a/query_test.go b/query_test.go index 27c75d1..8def6b3 100644 --- a/query_test.go +++ b/query_test.go @@ -12,6 +12,17 @@ func TestQueryAppend(t *testing.T) { } testCases := []TestCase{ + // Append without parameters + { + 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`, + ExpectedParams: map[string]any{}, + }, // Append with parameters { Input: NewQuery(). @@ -40,7 +51,7 @@ RETURN doc`, "title": "Spaghetti", }, }, - // Append and bind + // Append without parameters and bind after { Input: NewQuery(). Append("FOR doc IN @@collection").