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

Function TestGitignoresService_Get

github/gitignore_test.go:46–79  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

44}
45
46func TestGitignoresService_Get(t *testing.T) {
47 t.Parallel()
48 client, mux, _ := setup(t)
49
50 mux.HandleFunc("/gitignore/templates/name", func(w http.ResponseWriter, r *http.Request) {
51 testMethod(t, r, "GET")
52 fmt.Fprint(w, `{"name":"Name","source":"template source"}`)
53 })
54
55 ctx := t.Context()
56 gitignore, _, err := client.Gitignores.Get(ctx, "name")
57 if err != nil {
58 t.Errorf("Gitignores.List returned error: %v", err)
59 }
60
61 want := &Gitignore{Name: Ptr("Name"), Source: Ptr("template source")}
62 if !cmp.Equal(gitignore, want) {
63 t.Errorf("Gitignores.Get returned %+v, want %+v", gitignore, want)
64 }
65
66 const methodName = "Get"
67 testBadOptions(t, methodName, func() (err error) {
68 _, _, err = client.Gitignores.Get(ctx, "\n")
69 return err
70 })
71
72 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
73 got, resp, err := client.Gitignores.Get(ctx, "name")
74 if got != nil {
75 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
76 }
77 return resp, err
78 })
79}
80
81func TestGitignoresService_Get_invalidTemplate(t *testing.T) {
82 t.Parallel()

Callers

nothing calls this directly

Calls 7

testMethodFunction · 0.85
testBadOptionsFunction · 0.85
EqualMethod · 0.80
setupFunction · 0.70
PtrFunction · 0.70
GetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…