Skip to content

Commit 2d3520b

Browse files
committed
add unit tests for #342 - CreateImpersonation and DeleteImpersonation
Change-Id: Ib5fd4e99b88ff01e3363e049177326b7ee97be93
1 parent 07a1059 commit 2d3520b

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

github/authorizations_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,3 +306,38 @@ func TestDeleteGrant(t *testing.T) {
306306
t.Errorf("OAuthAuthorizations.DeleteGrant returned error: %v", err)
307307
}
308308
}
309+
310+
func TestAuthorizationsService_CreateImpersonation(t *testing.T) {
311+
setup()
312+
defer teardown()
313+
314+
mux.HandleFunc("/admin/users/u/authorizations", func(w http.ResponseWriter, r *http.Request) {
315+
testMethod(t, r, "POST")
316+
fmt.Fprint(w, `{"id":1}`)
317+
})
318+
319+
req := &AuthorizationRequest{Scopes: []Scope{ScopePublicRepo}}
320+
got, _, err := client.Authorizations.CreateImpersonation("u", req)
321+
if err != nil {
322+
t.Errorf("Authorizations.CreateImpersonation returned error: %+v", err)
323+
}
324+
325+
want := &Authorization{ID: Int(1)}
326+
if !reflect.DeepEqual(got, want) {
327+
t.Errorf("Authorizations.CreateImpersonation returned %+v, want %+v", *got.ID, *want.ID)
328+
}
329+
}
330+
331+
func TestAuthorizationsService_DeleteImpersonation(t *testing.T) {
332+
setup()
333+
defer teardown()
334+
335+
mux.HandleFunc("/admin/users/u/authorizations", func(w http.ResponseWriter, r *http.Request) {
336+
testMethod(t, r, "DELETE")
337+
})
338+
339+
_, err := client.Authorizations.DeleteImpersonation("u")
340+
if err != nil {
341+
t.Errorf("Authorizations.DeleteImpersonation returned error: %+v", err)
342+
}
343+
}

0 commit comments

Comments
 (0)