params_test.go 703 B

1234567891011121314151617181920212223242526272829303132333435
  1. package arango
  2. import "testing"
  3. func TestReadParams(t *testing.T) {
  4. type TestCase struct {
  5. Input string
  6. Output []string
  7. }
  8. testCases := []TestCase{
  9. {
  10. Input: "FOR doc IN @@collection FILTER doc.title == @title RETURN doc",
  11. Output: []string{"collection", "title"},
  12. },
  13. }
  14. for _, testCase := range testCases {
  15. t.Log("Input:", testCase.Input)
  16. t.Log("Expected output:", testCase.Output)
  17. params := ReadParams(testCase.Input)
  18. if len(params) != len(testCase.Output) {
  19. t.Errorf("Expected %d parameters", len(testCase.Output))
  20. break
  21. }
  22. for i, name := range testCase.Output {
  23. if params[i] != name {
  24. t.Errorf("Expected parameter %d to be %q", i, name)
  25. }
  26. }
  27. }
  28. }