(t *testing.T)
| 142 | } |
| 143 | |
| 144 | func TestExtractTargetRepoFromMap(t *testing.T) { |
| 145 | tests := []struct { |
| 146 | name string |
| 147 | input map[string]any |
| 148 | expected string |
| 149 | }{ |
| 150 | { |
| 151 | name: "valid target-repo", |
| 152 | input: map[string]any{ |
| 153 | "target-repo": "owner/repo", |
| 154 | }, |
| 155 | expected: "owner/repo", |
| 156 | }, |
| 157 | { |
| 158 | name: "wildcard target-repo (returns * for caller to validate)", |
| 159 | input: map[string]any{ |
| 160 | "target-repo": "*", |
| 161 | }, |
| 162 | expected: "*", |
| 163 | }, |
| 164 | { |
| 165 | name: "missing target-repo field", |
| 166 | input: map[string]any{}, |
| 167 | expected: "", |
| 168 | }, |
| 169 | { |
| 170 | name: "target-repo as non-string type", |
| 171 | input: map[string]any{ |
| 172 | "target-repo": 123, |
| 173 | }, |
| 174 | expected: "", |
| 175 | }, |
| 176 | { |
| 177 | name: "target-repo with organization and repo", |
| 178 | input: map[string]any{ |
| 179 | "target-repo": "github/docs", |
| 180 | }, |
| 181 | expected: "github/docs", |
| 182 | }, |
| 183 | } |
| 184 | |
| 185 | for _, tt := range tests { |
| 186 | t.Run(tt.name, func(t *testing.T) { |
| 187 | result := extractStringFromMap(tt.input, "target-repo", nil) |
| 188 | if result != tt.expected { |
| 189 | t.Errorf("expected %q, got %q", tt.expected, result) |
| 190 | } |
| 191 | }) |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | // Integration tests to verify the helpers work correctly in the parser functions |
| 196 |
nothing calls this directly
no test coverage detected