(t *testing.T)
| 21 | ) |
| 22 | |
| 23 | func TestDeployCmd_ArgsValidation(t *testing.T) { |
| 24 | dirs.RemoveAllForTest() |
| 25 | |
| 26 | tests := []struct { |
| 27 | name string |
| 28 | args []string |
| 29 | setSnapshot bool |
| 30 | snapshotValue string |
| 31 | expectError bool |
| 32 | expectedSnapshotPath string |
| 33 | }{ |
| 34 | { |
| 35 | name: "default_no_snapshot_should_succeed", |
| 36 | args: []string{}, |
| 37 | expectError: false, |
| 38 | }, |
| 39 | { |
| 40 | name: "positional_args_should_fail", |
| 41 | args: []string{"unexpected"}, |
| 42 | expectError: true, |
| 43 | }, |
| 44 | { |
| 45 | name: "empty_snapshot_should_fail", |
| 46 | setSnapshot: true, |
| 47 | snapshotValue: "", |
| 48 | expectError: true, |
| 49 | }, |
| 50 | { |
| 51 | name: "dot_snapshot_should_succeed", |
| 52 | setSnapshot: true, |
| 53 | snapshotValue: ".", |
| 54 | expectError: false, |
| 55 | expectedSnapshotPath: filepath.Clean("."), |
| 56 | }, |
| 57 | { |
| 58 | name: "parent_snapshot_should_succeed", |
| 59 | setSnapshot: true, |
| 60 | snapshotValue: "..", |
| 61 | expectError: false, |
| 62 | expectedSnapshotPath: filepath.Clean(".."), |
| 63 | }, |
| 64 | { |
| 65 | name: "escape_workspace_should_succeed", |
| 66 | setSnapshot: true, |
| 67 | snapshotValue: "../snapshots/2026-02-21", |
| 68 | expectError: false, |
| 69 | expectedSnapshotPath: filepath.Clean("../snapshots/2026-02-21"), |
| 70 | }, |
| 71 | { |
| 72 | name: "absolute_snapshot_should_succeed", |
| 73 | setSnapshot: true, |
| 74 | snapshotValue: filepath.Join(dirs.WorkspaceDir, "snapshots", "2026-02-21"), |
| 75 | expectError: false, |
| 76 | expectedSnapshotPath: filepath.Clean(filepath.Join(dirs.WorkspaceDir, "snapshots", "2026-02-21")), |
| 77 | }, |
| 78 | { |
| 79 | name: "valid_relative_snapshot_should_succeed", |
| 80 | setSnapshot: true, |
nothing calls this directly
no test coverage detected