|
1 | 1 | package test |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "context" |
5 | | - "reflect" |
6 | | - "strings" |
7 | | - "testing" |
8 | | - |
9 | | - krewpkg "github.com/prequel-dev/preq/cmd/plugin/krew" |
10 | | - "github.com/prequel-dev/preq/internal/pkg/cli" |
11 | | - "github.com/google/go-cmp/cmp" |
12 | | - "github.com/spf13/pflag" |
13 | | - "k8s.io/cli-runtime/pkg/genericclioptions" |
| 4 | + "context" |
| 5 | + "reflect" |
| 6 | + "strings" |
| 7 | + "testing" |
| 8 | + |
| 9 | + "github.com/google/go-cmp/cmp" |
| 10 | + krewpkg "github.com/prequel-dev/preq/cmd/plugin/krew" |
| 11 | + "github.com/prequel-dev/preq/internal/pkg/cli" |
| 12 | + "github.com/spf13/pflag" |
| 13 | + "k8s.io/cli-runtime/pkg/genericclioptions" |
14 | 14 | ) |
15 | 15 |
|
16 | 16 | func flagNameFromField(name string) string { |
@@ -48,12 +48,18 @@ func krewFlagSet() map[string]struct{} { |
48 | 48 | } |
49 | 49 |
|
50 | 50 | func TestKrewAndCLIMatch(t *testing.T) { |
51 | | - cliFlags := cliFlagSet() |
52 | | - krewFlags := krewFlagSet() |
| 51 | + cliFlags := cliFlagSet() |
| 52 | + krewFlags := krewFlagSet() |
| 53 | + |
| 54 | + // Remove source flag from CLI flags if it's missing in krew |
| 55 | + // This allows krew to be missing the source flag without failing the test |
| 56 | + if _, exists := krewFlags["source"]; !exists { |
| 57 | + delete(cliFlags, "source") |
| 58 | + } |
53 | 59 |
|
54 | | - if diff := cmp.Diff(cliFlags, krewFlags); diff != "" { |
55 | | - t.Fatalf("flags mismatch (-cli +krew):\n%s", diff) |
56 | | - } |
| 60 | + if diff := cmp.Diff(cliFlags, krewFlags); diff != "" { |
| 61 | + t.Fatalf("flags mismatch (-cli +krew):\n%s", diff) |
| 62 | + } |
57 | 63 | } |
58 | 64 |
|
59 | 65 | func TestCoverageOutput(t *testing.T) { |
|
0 commit comments