MCPcopy Create free account
hub / github.com/golang/appengine / TestBasicUserAPI

Function TestBasicUserAPI

v2/user/user_test.go:38–73  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

36}
37
38func TestBasicUserAPI(t *testing.T) {
39 for i, tc := range basicUserTests {
40 req := baseReq()
41 req.Header.Set("X-AppEngine-User-Nickname", tc.nickname)
42 req.Header.Set("X-AppEngine-User-Email", tc.email)
43 req.Header.Set("X-AppEngine-Auth-Domain", tc.authDomain)
44 req.Header.Set("X-AppEngine-User-Is-Admin", tc.admin)
45
46 c := internal.ContextForTesting(req)
47
48 if ga := IsAdmin(c); ga != tc.isAdmin {
49 t.Errorf("test %d: expected IsAdmin(c) = %v, got %v", i, tc.isAdmin, ga)
50 }
51
52 u := Current(c)
53 if tc.isNil {
54 if u != nil {
55 t.Errorf("test %d: expected u == nil, got %+v", i, u)
56 }
57 continue
58 }
59 if u == nil {
60 t.Errorf("test %d: expected u != nil, got nil", i)
61 continue
62 }
63 if u.Email != tc.email {
64 t.Errorf("test %d: expected u.Email = %q, got %q", i, tc.email, u.Email)
65 }
66 if gs := u.String(); gs != tc.displayName {
67 t.Errorf("test %d: expected u.String() = %q, got %q", i, tc.displayName, gs)
68 }
69 if u.Admin != tc.isAdmin {
70 t.Errorf("test %d: expected u.Admin = %v, got %v", i, tc.isAdmin, u.Admin)
71 }
72 }
73}
74
75func TestLoginURL(t *testing.T) {
76 expectedQuery := &pb.CreateLoginURLRequest{

Callers

nothing calls this directly

Calls 6

ContextForTestingFunction · 0.92
baseReqFunction · 0.70
IsAdminFunction · 0.70
CurrentFunction · 0.70
SetMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…