standardise arango tests

This commit is contained in:
Aneurin Barker Snook
2023-10-08 15:55:20 +01:00
parent 3c23ea8cde
commit 1fa7101a70
3 changed files with 75 additions and 29 deletions
+17 -5
View File
@@ -9,6 +9,13 @@ func TestReadParams(t *testing.T) {
}
testCases := []TestCase{
{
Input: "FOR doc IN recipes FILTER doc.title == \"Spaghetti\" RETURN doc",
},
{
Input: "FOR doc IN recipes FILTER doc.title == @title RETURN doc",
Output: []string{"title"},
},
{
Input: "FOR doc IN @@collection FILTER doc.title == @title RETURN doc",
Output: []string{"collection", "title"},
@@ -16,19 +23,24 @@ func TestReadParams(t *testing.T) {
}
for _, tc := range testCases {
t.Log("Input:", tc.Input)
t.Log("Expected output:", tc.Output)
t.Logf("Testing %q", tc.Input)
params := ReadParams(tc.Input)
if params == nil {
t.Errorf("Expected empty slice, got nil")
continue
}
if len(params) != len(tc.Output) {
t.Errorf("Expected %d parameters", len(tc.Output))
break
}
for i, name := range tc.Output {
if params[i] != name {
t.Errorf("Expected parameter %d to be %q", i, name)
if i == len(params) {
break
}
if name != params[i] {
t.Errorf("Expected %s for parameter %d, got %s", name, i, params[i])
}
}
}