MCPcopy Index your code
hub / github.com/google/go-github / TestOrganizationsService_Get

Function TestOrganizationsService_Get

github/orgs_test.go:183–217  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

181}
182
183func TestOrganizationsService_Get(t *testing.T) {
184 t.Parallel()
185 client, mux, _ := setup(t)
186
187 mux.HandleFunc("/orgs/o", func(w http.ResponseWriter, r *http.Request) {
188 testMethod(t, r, "GET")
189 testHeader(t, r, "Accept", mediaTypeMemberAllowedRepoCreationTypePreview)
190 fmt.Fprint(w, `{"id":1, "login":"l", "url":"u", "avatar_url": "a", "location":"l"}`)
191 })
192
193 ctx := t.Context()
194 org, _, err := client.Organizations.Get(ctx, "o")
195 if err != nil {
196 t.Errorf("Organizations.Get returned error: %v", err)
197 }
198
199 want := &Organization{ID: Ptr(int64(1)), Login: Ptr("l"), URL: Ptr("u"), AvatarURL: Ptr("a"), Location: Ptr("l")}
200 if !cmp.Equal(org, want) {
201 t.Errorf("Organizations.Get returned %+v, want %+v", org, want)
202 }
203
204 const methodName = "Get"
205 testBadOptions(t, methodName, func() (err error) {
206 _, _, err = client.Organizations.Get(ctx, "\n")
207 return err
208 })
209
210 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
211 got, resp, err := client.Organizations.Get(ctx, "o")
212 if got != nil {
213 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
214 }
215 return resp, err
216 })
217}
218
219func TestOrganizationsService_Get_invalidOrg(t *testing.T) {
220 t.Parallel()

Callers

nothing calls this directly

Calls 8

testMethodFunction · 0.85
testHeaderFunction · 0.85
testBadOptionsFunction · 0.85
EqualMethod · 0.80
setupFunction · 0.70
PtrFunction · 0.70
GetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…