(t *testing.T)
| 50 | } |
| 51 | |
| 52 | func TestPluginMatch(t *testing.T) { |
| 53 | testCases := []struct { |
| 54 | doc string |
| 55 | commandString string |
| 56 | pluginConfig map[string]string |
| 57 | cmdErrorMessage string |
| 58 | expectedMatch string |
| 59 | expectedOk bool |
| 60 | }{ |
| 61 | { |
| 62 | doc: "hooks prefix match", |
| 63 | commandString: "image ls", |
| 64 | pluginConfig: map[string]string{ |
| 65 | "hooks": "image", |
| 66 | }, |
| 67 | expectedMatch: "image", |
| 68 | expectedOk: true, |
| 69 | }, |
| 70 | { |
| 71 | doc: "hooks no match", |
| 72 | commandString: "context ls", |
| 73 | pluginConfig: map[string]string{ |
| 74 | "hooks": "build", |
| 75 | }, |
| 76 | expectedMatch: "", |
| 77 | expectedOk: false, |
| 78 | }, |
| 79 | { |
| 80 | doc: "hooks exact match", |
| 81 | commandString: "context ls", |
| 82 | pluginConfig: map[string]string{ |
| 83 | "hooks": "context ls", |
| 84 | }, |
| 85 | expectedMatch: "context ls", |
| 86 | expectedOk: true, |
| 87 | }, |
| 88 | { |
| 89 | doc: "hooks first match wins", |
| 90 | commandString: "image ls", |
| 91 | pluginConfig: map[string]string{ |
| 92 | "hooks": "image ls,image", |
| 93 | }, |
| 94 | expectedMatch: "image ls", |
| 95 | expectedOk: true, |
| 96 | }, |
| 97 | { |
| 98 | doc: "hooks empty string", |
| 99 | commandString: "image ls", |
| 100 | pluginConfig: map[string]string{ |
| 101 | "hooks": "", |
| 102 | }, |
| 103 | expectedMatch: "", |
| 104 | expectedOk: false, |
| 105 | }, |
| 106 | { |
| 107 | doc: "hooks partial token no match", |
| 108 | commandString: "image inspect", |
| 109 | pluginConfig: map[string]string{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…