9
type aliasTestcase struct {
14
func slicesEqual(a, b []string) bool {
15
if a == nil && b == nil {
19
if a == nil || b == nil {
36
func TestExpandAliases(t *testing.T) {
37
aliases := map[string]string{
39
"foo": "list @ARGS@ -c n",
42
testcases := []aliasTestcase{
44
input: []string{"lxc", "list"},
45
expected: []string{"lxc", "list"},
48
input: []string{"lxc", "tester", "12"},
49
expected: []string{"lxc", "list", "--no-alias"},
52
input: []string{"lxc", "foo", "asdf"},
53
expected: []string{"lxc", "list", "--no-alias", "asdf", "-c", "n"},
57
conf := &lxd.Config{Aliases: aliases}
59
for _, tc := range testcases {
60
result, expanded := expandAlias(conf, tc.input)
62
if !slicesEqual(tc.input, tc.expected) {
63
t.Errorf("didn't expand when expected to: %s", tc.input)
68
if !slicesEqual(result, tc.expected) {
69
t.Errorf("%s didn't match %s", result, tc.expected)