add empty params test
This commit is contained in:
+7
-8
@@ -12,15 +12,10 @@ func TestQueryAppend(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testCases := []TestCase{
|
testCases := []TestCase{
|
||||||
// Append without parameters
|
// Initialise empty query
|
||||||
{
|
{
|
||||||
Input: NewQuery().
|
Input: NewQuery(),
|
||||||
Append("FOR doc IN @@collection").
|
ExpectedStr: "",
|
||||||
Append("FILTER doc.title == @title").
|
|
||||||
Append("RETURN doc"),
|
|
||||||
ExpectedStr: `FOR doc IN @@collection
|
|
||||||
FILTER doc.title == @title
|
|
||||||
RETURN doc`,
|
|
||||||
ExpectedParams: map[string]any{},
|
ExpectedParams: map[string]any{},
|
||||||
},
|
},
|
||||||
// Append with parameters
|
// Append with parameters
|
||||||
@@ -93,6 +88,10 @@ RETURN doc`,
|
|||||||
t.Errorf("Expected %q, got %q", tc.ExpectedStr, actualStr)
|
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) {
|
if len(tc.Input.Params) != len(tc.ExpectedParams) {
|
||||||
t.Errorf("Expected %d parameters, got %d", len(tc.ExpectedParams), len(tc.Input.Params))
|
t.Errorf("Expected %d parameters, got %d", len(tc.ExpectedParams), len(tc.Input.Params))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user