(t *testing.T)
| 18 | ) |
| 19 | |
| 20 | func TestUpdateCmd_CommandStructure(t *testing.T) { |
| 21 | // Cleanup. |
| 22 | dirs.RemoveAllForTest() |
| 23 | |
| 24 | updateCmd := updateCmd{} |
| 25 | celer := configs.NewCeler() |
| 26 | cmd := updateCmd.Command(celer) |
| 27 | |
| 28 | // Test command basic properties. |
| 29 | if cmd.Use != "update" { |
| 30 | t.Errorf("Expected Use to be 'update', got '%s'", cmd.Use) |
| 31 | } |
| 32 | |
| 33 | if cmd.Short == "" { |
| 34 | t.Error("Short description should not be empty") |
| 35 | } |
| 36 | |
| 37 | if cmd.Long == "" { |
| 38 | t.Error("Long description should not be empty") |
| 39 | } |
| 40 | |
| 41 | // Test flags. |
| 42 | tests := []struct { |
| 43 | flagName string |
| 44 | shorthand string |
| 45 | defaultValue string |
| 46 | }{ |
| 47 | {"conf-repo", "c", "false"}, |
| 48 | {"ports-repo", "p", "false"}, |
| 49 | {"force", "f", "false"}, |
| 50 | {"recursive", "r", "false"}, |
| 51 | } |
| 52 | |
| 53 | for _, test := range tests { |
| 54 | t.Run(test.flagName, func(t *testing.T) { |
| 55 | flag := cmd.Flags().Lookup(test.flagName) |
| 56 | if flag == nil { |
| 57 | t.Errorf("Flag --%s should be defined", test.flagName) |
| 58 | return |
| 59 | } |
| 60 | |
| 61 | if flag.Shorthand != test.shorthand { |
| 62 | t.Errorf("Expected shorthand %s, got %s", test.shorthand, flag.Shorthand) |
| 63 | } |
| 64 | |
| 65 | if flag.DefValue != test.defaultValue { |
| 66 | t.Errorf("Expected default value %s, got %s", test.defaultValue, flag.DefValue) |
| 67 | } |
| 68 | }) |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | func TestUpdateCmd_ArgsValidation(t *testing.T) { |
| 73 | // Cleanup. |
nothing calls this directly
no test coverage detected