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

Function TestBasicUserAPI

user/user_test.go:41–76  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

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