diff --git a/cmd/shared_test.go b/cmd/shared_test.go index 677f745..8355844 100644 --- a/cmd/shared_test.go +++ b/cmd/shared_test.go @@ -25,20 +25,46 @@ func TestFilterCompletion(t *testing.T) { path: ProjectMultiLevelPath, expect: []string{"customer==", "customer!=", "customer^=", "customer~=", "customer$="}, }, + "multi-level with 'customer' should return var with operators": { + toComplete: "customer", + path: ProjectMultiLevelPath, + expect: []string{"customer==", "customer!=", "customer^=", "customer~=", "customer$="}, + }, "multi-level with 'p' should return all vars": { toComplete: "p", path: ProjectMultiLevelPath, expect: []string{"platform==", "platform!=", "platform^=", "platform~=", "platform$="}, }, - "multi-level with 'customer' should return var with operators": { - toComplete: "", + + "multi-level with 'customer==' should return with values": { + toComplete: "customer==", + path: ProjectMultiLevelPath, + expect: []string{"customer==customer1", "customer==customer2", "customer==customer3"}, + }, + "multi-level with 'customer!=' should return with values": { + toComplete: "customer!=", + path: ProjectMultiLevelPath, + expect: []string{"customer!=customer1", "customer!=customer2", "customer!=customer3"}, + }, + "multi-level with 'customer$=' should return with values": { + toComplete: "customer$=", + path: ProjectMultiLevelPath, + expect: []string{"customer$=customer1", "customer$=customer2", "customer$=customer3"}, + }, + "multi-level with 'customer~=' should return with values": { + toComplete: "customer~=", + path: ProjectMultiLevelPath, + expect: []string{"customer~=customer1", "customer~=customer2", "customer~=customer3"}, + }, + "multi-level with 'customer^=' should return with values": { + toComplete: "customer^=", path: ProjectMultiLevelPath, - expect: []string{"customer", "env", "os", "platform"}, + expect: []string{"customer^=customer1", "customer^=customer2", "customer^=customer3"}, }, - "multi-level with 'customer==' should return var with operators": { - toComplete: "", + "multi-level with 'customer%=' should return with nothing": { + toComplete: "customer%=", path: ProjectMultiLevelPath, - expect: []string{"customer", "env", "os", "platform"}, + expect: []string{}, }, } @@ -51,7 +77,6 @@ func TestFilterCompletion(t *testing.T) { } -// //func TestTagsCompletion(t *testing.T) { // testCases := map[string]struct { // toComplete string @@ -80,3 +105,44 @@ func TestFilterCompletion(t *testing.T) { // } // //} + +//func TestPlaybookCompletion(t *testing.T) { +// testCases := map[string]struct { +// toComplete string +// path string +// expect []string +// }{"multi-level with black should return all vars": { +// toComplete: "", +// path: ProjectMultiLevelPath, +// expect: []string{"customer", "env", "os", "platform"}, +// }, +// "multi-level with 'c' should should return customer with operators": { +// toComplete: "c", +// path: ProjectMultiLevelPath, +// expect: []string{"customer==", "customer!=", "customer^=", "customer~=", "customer$="}, +// }, +// "multi-level with 'p' should return all vars": { +// toComplete: "p", +// path: ProjectMultiLevelPath, +// expect: []string{"platform==", "platform!=", "platform^=", "platform~=", "platform$="}, +// }, +// "multi-level with 'customer' should return var with operators": { +// toComplete: "", +// path: ProjectMultiLevelPath, +// expect: []string{"customer", "env", "os", "platform"}, +// }, +// "multi-level with 'customer==' should return var with operators": { +// toComplete: "", +// path: ProjectMultiLevelPath, +// expect: []string{"customer", "env", "os", "platform"}, +// }, +// } +// +// for testName, testCase := range testCases { +// t.Run(testName, func(t *testing.T) { +// actual, _ := playbookCompletion(testCase.toComplete, testCase.path) +// assert.Equal(t, testCase.expect, actual) +// }) +// } +// +//}