MCPcopy Create free account
hub / github.com/google/go-github / TestActivity_Starring

Function TestActivity_Starring

test/integration/activity_test.go:21–72  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19)
20
21func TestActivity_Starring(t *testing.T) {
22 stargazers, _, err := client.Activity.ListStargazers(t.Context(), owner, repo, nil)
23 if err != nil {
24 t.Fatalf("Activity.ListStargazers returned error: %v", err)
25 }
26
27 if len(stargazers) == 0 {
28 t.Errorf("Activity.ListStargazers(%q, %q) returned no stargazers", owner, repo)
29 }
30
31 // the rest of the tests requires auth
32 skipIfMissingAuth(t)
33
34 // first, check if already starred the target repository
35 star, _, err := client.Activity.IsStarred(t.Context(), owner, repo)
36 if err != nil {
37 t.Fatalf("Activity.IsStarred returned error: %v", err)
38 }
39 if star {
40 t.Fatalf("Already starring %v/%v. Please manually unstar it first.", owner, repo)
41 }
42
43 // star the target repository
44 _, err = client.Activity.Star(t.Context(), owner, repo)
45 if err != nil {
46 t.Fatalf("Activity.Star returned error: %v", err)
47 }
48
49 // check again and verify starred
50 star, _, err = client.Activity.IsStarred(t.Context(), owner, repo)
51 if err != nil {
52 t.Fatalf("Activity.IsStarred returned error: %v", err)
53 }
54 if !star {
55 t.Fatalf("Not starred %v/%v after starring it.", owner, repo)
56 }
57
58 // unstar
59 _, err = client.Activity.Unstar(t.Context(), owner, repo)
60 if err != nil {
61 t.Fatalf("Activity.Unstar returned error: %v", err)
62 }
63
64 // check again and verify not watching
65 star, _, err = client.Activity.IsStarred(t.Context(), owner, repo)
66 if err != nil {
67 t.Fatalf("Activity.IsStarred returned error: %v", err)
68 }
69 if star {
70 t.Fatalf("Still starred %v/%v after unstarring it.", owner, repo)
71 }
72}
73
74func deleteSubscription(t *testing.T) {
75 // delete subscription

Callers

nothing calls this directly

Calls 5

skipIfMissingAuthFunction · 0.85
ListStargazersMethod · 0.80
IsStarredMethod · 0.45
StarMethod · 0.45
UnstarMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…