123456789101112131415161718192021222324252627282930 |
- package web
- import (
- "net/url"
- "testing"
- )
- func Test__getOp(t *testing.T) {
- empty := []string{""}
- for _, test := range [...]struct {
- name string
- input url.Values
- expected QueueOp
- }{
- {"delete", url.Values{"delete": empty}, OpDelete},
- {"redrive", url.Values{"redrive": empty}, OpRedrive},
- {"none", url.Values{"whatever": empty}, OpInvalid},
- {"both", url.Values{"delete": nil, "redrive": nil}, OpInvalid},
- } {
- t.Run(test.name, func(t *testing.T) {
- var u = url.URL{
- RawQuery: test.input.Encode(),
- }
- actual := getOp(&u)
- if actual != test.expected {
- t.Errorf("got %s but expected %s", actual, test.expected)
- }
- })
- }
- }
|