(t *testing.T)
| 104 | } |
| 105 | |
| 106 | func TestRepositoriesService_CreateKey(t *testing.T) { |
| 107 | t.Parallel() |
| 108 | client, mux, _ := setup(t) |
| 109 | |
| 110 | input := &Key{Key: Ptr("k"), Title: Ptr("t")} |
| 111 | |
| 112 | mux.HandleFunc("/repos/o/r/keys", func(w http.ResponseWriter, r *http.Request) { |
| 113 | testMethod(t, r, "POST") |
| 114 | testJSONBody(t, r, input) |
| 115 | fmt.Fprint(w, `{"id":1}`) |
| 116 | }) |
| 117 | |
| 118 | ctx := t.Context() |
| 119 | key, _, err := client.Repositories.CreateKey(ctx, "o", "r", input) |
| 120 | if err != nil { |
| 121 | t.Errorf("Repositories.GetKey returned error: %v", err) |
| 122 | } |
| 123 | |
| 124 | want := &Key{ID: Ptr(int64(1))} |
| 125 | if !cmp.Equal(key, want) { |
| 126 | t.Errorf("Repositories.GetKey returned %+v, want %+v", key, want) |
| 127 | } |
| 128 | |
| 129 | const methodName = "CreateKey" |
| 130 | testBadOptions(t, methodName, func() (err error) { |
| 131 | _, _, err = client.Repositories.CreateKey(ctx, "\n", "\n", input) |
| 132 | return err |
| 133 | }) |
| 134 | |
| 135 | testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 136 | got, resp, err := client.Repositories.CreateKey(ctx, "o", "r", input) |
| 137 | if got != nil { |
| 138 | t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) |
| 139 | } |
| 140 | return resp, err |
| 141 | }) |
| 142 | } |
| 143 | |
| 144 | func TestRepositoriesService_CreateKey_invalidOwner(t *testing.T) { |
| 145 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…