(t *testing.T)
| 85 | } |
| 86 | |
| 87 | func TestDeleteRun(t *testing.T) { |
| 88 | tests := []struct { |
| 89 | name string |
| 90 | config string |
| 91 | isTTY bool |
| 92 | opts *DeleteOptions |
| 93 | wantAliases map[string]string |
| 94 | wantStdout string |
| 95 | wantStderr string |
| 96 | wantErrMsg string |
| 97 | }{ |
| 98 | { |
| 99 | name: "delete alias", |
| 100 | config: heredoc.Doc(` |
| 101 | aliases: |
| 102 | il: issue list |
| 103 | co: pr checkout |
| 104 | `), |
| 105 | isTTY: true, |
| 106 | opts: &DeleteOptions{ |
| 107 | Name: "co", |
| 108 | All: false, |
| 109 | }, |
| 110 | wantAliases: map[string]string{ |
| 111 | "il": "issue list", |
| 112 | }, |
| 113 | wantStderr: "✓ Deleted alias co; was pr checkout\n", |
| 114 | }, |
| 115 | { |
| 116 | name: "delete all aliases", |
| 117 | config: heredoc.Doc(` |
| 118 | aliases: |
| 119 | il: issue list |
| 120 | co: pr checkout |
| 121 | `), |
| 122 | isTTY: true, |
| 123 | opts: &DeleteOptions{ |
| 124 | All: true, |
| 125 | }, |
| 126 | wantAliases: map[string]string{}, |
| 127 | wantStderr: "✓ Deleted alias co; was pr checkout\n✓ Deleted alias il; was issue list\n", |
| 128 | }, |
| 129 | { |
| 130 | name: "delete alias that does not exist", |
| 131 | config: heredoc.Doc(` |
| 132 | aliases: |
| 133 | il: issue list |
| 134 | co: pr checkout |
| 135 | `), |
| 136 | isTTY: true, |
| 137 | opts: &DeleteOptions{ |
| 138 | Name: "unknown", |
| 139 | }, |
| 140 | wantAliases: map[string]string{ |
| 141 | "il": "issue list", |
| 142 | "co": "pr checkout", |
| 143 | }, |
| 144 | wantErrMsg: "no such alias unknown", |
nothing calls this directly
no test coverage detected