2021-06-25 08:42:47 +00:00
|
|
|
package docker
|
2020-11-23 14:26:52 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetFiltersQueryArg(t *testing.T) {
|
|
|
|
f := func(filters []Filter, queryArgExpected string) {
|
|
|
|
t.Helper()
|
|
|
|
queryArg := getFiltersQueryArg(filters)
|
|
|
|
if queryArg != queryArgExpected {
|
|
|
|
t.Fatalf("unexpected query arg; got %s; want %s", queryArg, queryArgExpected)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
f(nil, "")
|
|
|
|
f([]Filter{
|
|
|
|
{
|
2020-11-23 14:52:53 +00:00
|
|
|
Name: "name",
|
2020-11-23 14:26:52 +00:00
|
|
|
Values: []string{"foo", "bar"},
|
|
|
|
},
|
|
|
|
{
|
2020-11-23 14:52:53 +00:00
|
|
|
Name: "xxx",
|
2020-11-23 14:26:52 +00:00
|
|
|
Values: []string{"aa"},
|
|
|
|
},
|
|
|
|
}, "%7B%22name%22%3A%7B%22bar%22%3Atrue%2C%22foo%22%3Atrue%7D%2C%22xxx%22%3A%7B%22aa%22%3Atrue%7D%7D")
|
|
|
|
}
|