(t *testing.T)
| 111 | } |
| 112 | |
| 113 | func TestDeployCmd_Completion(t *testing.T) { |
| 114 | dirs.RemoveAllForTest() |
| 115 | |
| 116 | deploy := deployCmd{} |
| 117 | cmd := deploy.Command(configs.NewCeler()) |
| 118 | |
| 119 | tests := []struct { |
| 120 | name string |
| 121 | toComplete string |
| 122 | expected []string |
| 123 | }{ |
| 124 | { |
| 125 | name: "complete_long_force_flag", |
| 126 | toComplete: "--fo", |
| 127 | expected: []string{"--force"}, |
| 128 | }, |
| 129 | { |
| 130 | name: "complete_short_force_flag", |
| 131 | toComplete: "-f", |
| 132 | expected: []string{"-f"}, |
| 133 | }, |
| 134 | { |
| 135 | name: "complete_snapshot_flag", |
| 136 | toComplete: "--sna", |
| 137 | expected: []string{"--snapshot"}, |
| 138 | }, |
| 139 | } |
| 140 | |
| 141 | for _, test := range tests { |
| 142 | t.Run(test.name, func(t *testing.T) { |
| 143 | suggestions, directive := deploy.completion(cmd, []string{}, test.toComplete) |
| 144 | |
| 145 | if directive != cobra.ShellCompDirectiveNoFileComp { |
| 146 | t.Fatalf("expected directive %v, got %v", cobra.ShellCompDirectiveNoFileComp, directive) |
| 147 | } |
| 148 | |
| 149 | for _, expected := range test.expected { |
| 150 | if !slices.Contains(suggestions, expected) { |
| 151 | t.Fatalf("expected completion %s, got %v", expected, suggestions) |
| 152 | } |
| 153 | } |
| 154 | }) |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | // setupTestRepo creates a bare git repo as clone source in a temp directory |
| 159 | // and returns its path along with known commit hashes for testing. |
nothing calls this directly
no test coverage detected