This repository has been archived on 2026-10-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
aql/params_test.go
T

36 lines
661 B
Go
Raw Normal View History

2023-10-07 10:22:56 +01:00
package arango
import "testing"
func TestReadParams(t *testing.T) {
type TestCase struct {
Input string
Output []string
}
testCases := []TestCase{
{
Input: "FOR doc IN @@collection FILTER doc.title == @title RETURN doc",
Output: []string{"collection", "title"},
},
}
2023-10-07 10:44:47 +01:00
for _, tc := range testCases {
t.Log("Input:", tc.Input)
t.Log("Expected output:", tc.Output)
2023-10-07 10:22:56 +01:00
2023-10-07 10:44:47 +01:00
params := ReadParams(tc.Input)
2023-10-07 10:22:56 +01:00
2023-10-07 10:44:47 +01:00
if len(params) != len(tc.Output) {
t.Errorf("Expected %d parameters", len(tc.Output))
2023-10-07 10:22:56 +01:00
break
}
2023-10-07 10:44:47 +01:00
for i, name := range tc.Output {
2023-10-07 10:22:56 +01:00
if params[i] != name {
t.Errorf("Expected parameter %d to be %q", i, name)
}
}
}
}