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

Function TestUsers_Update

test/integration/users_test.go:48–91  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

46}
47
48func TestUsers_Update(t *testing.T) {
49 skipIfMissingAuth(t)
50
51 u, _, err := client.Users.Get(t.Context(), "")
52 if err != nil {
53 t.Fatalf("Users.Get('') returned error: %v", err)
54 }
55
56 if *u.Login == "" {
57 t.Error("wanted non-empty values for user.Login")
58 }
59
60 // save original location
61 var location string
62 if u.Location != nil {
63 location = *u.Location
64 }
65
66 // update location to test value
67 testLoc := fmt.Sprintf("test-%v", rand.Int())
68 u.Location = &testLoc
69
70 _, _, err = client.Users.Edit(t.Context(), u)
71 if err != nil {
72 t.Fatalf("Users.Update returned error: %v", err)
73 }
74
75 // refetch user and check location value
76 u, _, err = client.Users.Get(t.Context(), "")
77 if err != nil {
78 t.Fatalf("Users.Get('') returned error: %v", err)
79 }
80
81 if testLoc != *u.Location {
82 t.Errorf("Users.Get('') has location: %v, want: %v", *u.Location, testLoc)
83 }
84
85 // set location back to the original value
86 u.Location = &location
87 _, _, err = client.Users.Edit(t.Context(), u)
88 if err != nil {
89 t.Fatalf("Users.Edit returned error: %v", err)
90 }
91}
92
93func TestUsers_Emails(t *testing.T) {
94 skipIfMissingAuth(t)

Callers

nothing calls this directly

Calls 4

skipIfMissingAuthFunction · 0.85
GetMethod · 0.45
ErrorMethod · 0.45
EditMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…