(t *testing.T)
| 397 | } |
| 398 | |
| 399 | func TestCodespacesService_GetPublicKey(t *testing.T) { |
| 400 | t.Parallel() |
| 401 | type test struct { |
| 402 | name string |
| 403 | handleFunc func(*http.ServeMux) |
| 404 | call func(context.Context, *Client) (*PublicKey, *Response, error) |
| 405 | badCall func(context.Context, *Client) (*PublicKey, *Response, error) |
| 406 | methodName string |
| 407 | } |
| 408 | |
| 409 | tests := []*test{ |
| 410 | { |
| 411 | name: "User", |
| 412 | handleFunc: func(mux *http.ServeMux) { |
| 413 | mux.HandleFunc("/user/codespaces/secrets/public-key", func(w http.ResponseWriter, r *http.Request) { |
| 414 | testMethod(t, r, "GET") |
| 415 | fmt.Fprint(w, `{"key_id":"1234","key":"2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234"}`) |
| 416 | }) |
| 417 | }, |
| 418 | call: func(ctx context.Context, client *Client) (*PublicKey, *Response, error) { |
| 419 | return client.Codespaces.GetUserPublicKey(ctx) |
| 420 | }, |
| 421 | methodName: "GetUserPublicKey", |
| 422 | }, |
| 423 | { |
| 424 | name: "Org", |
| 425 | handleFunc: func(mux *http.ServeMux) { |
| 426 | mux.HandleFunc("/orgs/o/codespaces/secrets/public-key", func(w http.ResponseWriter, r *http.Request) { |
| 427 | testMethod(t, r, "GET") |
| 428 | fmt.Fprint(w, `{"key_id":"1234","key":"2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234"}`) |
| 429 | }) |
| 430 | }, |
| 431 | call: func(ctx context.Context, client *Client) (*PublicKey, *Response, error) { |
| 432 | return client.Codespaces.GetOrgPublicKey(ctx, "o") |
| 433 | }, |
| 434 | badCall: func(ctx context.Context, client *Client) (*PublicKey, *Response, error) { |
| 435 | return client.Codespaces.GetOrgPublicKey(ctx, "\n") |
| 436 | }, |
| 437 | methodName: "GetOrgPublicKey", |
| 438 | }, |
| 439 | { |
| 440 | name: "Repo", |
| 441 | handleFunc: func(mux *http.ServeMux) { |
| 442 | mux.HandleFunc("/repos/o/r/codespaces/secrets/public-key", func(w http.ResponseWriter, r *http.Request) { |
| 443 | testMethod(t, r, "GET") |
| 444 | fmt.Fprint(w, `{"key_id":"1234","key":"2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234"}`) |
| 445 | }) |
| 446 | }, |
| 447 | call: func(ctx context.Context, client *Client) (*PublicKey, *Response, error) { |
| 448 | return client.Codespaces.GetRepoPublicKey(ctx, "o", "r") |
| 449 | }, |
| 450 | badCall: func(ctx context.Context, client *Client) (*PublicKey, *Response, error) { |
| 451 | return client.Codespaces.GetRepoPublicKey(ctx, "\n", "\n") |
| 452 | }, |
| 453 | methodName: "GetRepoPublicKey", |
| 454 | }, |
| 455 | } |
| 456 |
nothing calls this directly
no test coverage detected
searching dependent graphs…