Debian Codegraph @

github/emojis_test.go

raw
1 // Copyright 2023 The go-github AUTHORS. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file.
5
6 package github
7
8 import (
9 "context"
10 "fmt"
11 "net/http"
12 "testing"
13
14 "github.com/google/go-cmp/cmp"
15 )
16
17 func TestEmojisService_List(t *testing.T) {
18 client, mux, _, teardown := setup()
19 defer teardown()
20
21 mux.HandleFunc("/emojis", func(w http.ResponseWriter, r *http.Request) {
22 testMethod(t, r, "GET")
23 fmt.Fprint(w, `{"+1": "+1.png"}`)
24 })
25
26 ctx := context.Background()
27 emoji, _, err := client.ListEmojis(ctx)
28 if err != nil {
29 t.Errorf("List returned error: %v", err)
30 }
31
32 want := map[string]string{"+1": "+1.png"}
33 if !cmp.Equal(want, emoji) {
34 t.Errorf("List returned %+v, want %+v", emoji, want)
35 }
36
37 const methodName = "List"
38 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
39 got, resp, err := client.Emojis.List(ctx)
40 if got != nil {
41 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
42 }
43 return resp, err
44 })
45 }