(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestNewEnvCommand(t *testing.T) { |
| 15 | cmd := NewEnvCommand() |
| 16 | require.NotNil(t, cmd) |
| 17 | assert.Equal(t, "env", cmd.Use) |
| 18 | |
| 19 | var getCmd, updateCmd *cobra.Command |
| 20 | var hasGet, hasUpdate bool |
| 21 | for _, sub := range cmd.Commands() { |
| 22 | if sub.Name() == "get" { |
| 23 | hasGet = true |
| 24 | getCmd = sub |
| 25 | } |
| 26 | if sub.Name() == "update" { |
| 27 | hasUpdate = true |
| 28 | updateCmd = sub |
| 29 | } |
| 30 | } |
| 31 | assert.True(t, hasGet, "env command should include get subcommand") |
| 32 | assert.True(t, hasUpdate, "env command should include update subcommand") |
| 33 | require.NotNil(t, getCmd) |
| 34 | require.NotNil(t, updateCmd) |
| 35 | assert.NotEmpty(t, getCmd.Long) |
| 36 | assert.Contains(t, getCmd.Long, "file") |
| 37 | assert.Contains(t, getCmd.Long, "scope") |
| 38 | assert.Contains(t, getCmd.Long, "--enterprise") |
| 39 | assert.NotEmpty(t, updateCmd.Long) |
| 40 | assert.Contains(t, updateCmd.Long, "file") |
| 41 | assert.Contains(t, updateCmd.Long, "scope") |
| 42 | assert.Contains(t, updateCmd.Long, "--dry-run") |
| 43 | assert.Contains(t, updateCmd.Long, "--yes") |
| 44 | assert.NotNil(t, updateCmd.Flags().Lookup("yes")) |
| 45 | assert.NotNil(t, updateCmd.Flags().Lookup("dry-run")) |
| 46 | |
| 47 | getRepoFlag := getCmd.Flags().Lookup("repo") |
| 48 | require.NotNil(t, getRepoFlag) |
| 49 | assert.Equal(t, "r", getRepoFlag.Shorthand) |
| 50 | |
| 51 | updateRepoFlag := updateCmd.Flags().Lookup("repo") |
| 52 | require.NotNil(t, updateRepoFlag) |
| 53 | assert.Equal(t, "r", updateRepoFlag.Shorthand) |
| 54 | } |
| 55 | |
| 56 | func TestResolveDefaultsTarget(t *testing.T) { |
| 57 | orig := defaultsGetCurrentRepoSlug |
nothing calls this directly
no test coverage detected