Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
clementblaise committed Jan 27, 2021
1 parent d086e4d commit 9fc2dae
Showing 1 changed file with 73 additions and 7 deletions.
80 changes: 73 additions & 7 deletions cmd/shared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
},
}

Expand All @@ -51,7 +77,6 @@ func TestFilterCompletion(t *testing.T) {

}

//
//func TestTagsCompletion(t *testing.T) {
// testCases := map[string]struct {
// toComplete string
Expand Down Expand Up @@ -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)
// })
// }
//
//}

0 comments on commit 9fc2dae

Please sign in to comment.