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)
			}
		})
	}
}
