(t *testing.T)
| 215 | } |
| 216 | |
| 217 | func TestMeReplacer_Replace(t *testing.T) { |
| 218 | rtSuccess := &httpmock.Registry{} |
| 219 | rtSuccess.Register( |
| 220 | httpmock.GraphQL(`query UserCurrent\b`), |
| 221 | httpmock.StringResponse(` |
| 222 | { "data": { |
| 223 | "viewer": { "login": "ResolvedLogin" } |
| 224 | } } |
| 225 | `), |
| 226 | ) |
| 227 | |
| 228 | rtFailure := &httpmock.Registry{} |
| 229 | rtFailure.Register( |
| 230 | httpmock.GraphQL(`query UserCurrent\b`), |
| 231 | httpmock.StatusStringResponse(500, ` |
| 232 | { "data": { |
| 233 | "viewer": { } |
| 234 | } } |
| 235 | `), |
| 236 | ) |
| 237 | |
| 238 | type args struct { |
| 239 | logins []string |
| 240 | client *api.Client |
| 241 | repo ghrepo.Interface |
| 242 | } |
| 243 | tests := []struct { |
| 244 | name string |
| 245 | args args |
| 246 | verify func(t httpmock.Testing) |
| 247 | want []string |
| 248 | wantErr bool |
| 249 | }{ |
| 250 | { |
| 251 | name: "succeeds resolving the userlogin", |
| 252 | args: args{ |
| 253 | client: api.NewClientFromHTTP(&http.Client{Transport: rtSuccess}), |
| 254 | repo: ghrepo.New("OWNER", "REPO"), |
| 255 | logins: []string{"some", "@me", "other"}, |
| 256 | }, |
| 257 | verify: rtSuccess.Verify, |
| 258 | want: []string{"some", "ResolvedLogin", "other"}, |
| 259 | }, |
| 260 | { |
| 261 | name: "fails resolving the userlogin", |
| 262 | args: args{ |
| 263 | client: api.NewClientFromHTTP(&http.Client{Transport: rtFailure}), |
| 264 | repo: ghrepo.New("OWNER", "REPO"), |
| 265 | logins: []string{"some", "@me", "other"}, |
| 266 | }, |
| 267 | verify: rtFailure.Verify, |
| 268 | want: []string(nil), |
| 269 | wantErr: true, |
| 270 | }, |
| 271 | } |
| 272 | for _, tt := range tests { |
| 273 | t.Run(tt.name, func(t *testing.T) { |
| 274 | me := NewMeReplacer(tt.args.client, tt.args.repo.RepoHost()) |
nothing calls this directly
no test coverage detected