Debian Codegraph @

test/integration/misc_test.go

raw
1 // Copyright 2014 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 //go:build integration
7 // +build integration
8
9 package integration
10
11 import (
12 "context"
13 "testing"
14 "time"
15 )
16
17 func TestEmojis(t *testing.T) {
18 emoji, _, err := client.Emojis.List(context.Background())
19 if err != nil {
20 t.Fatalf("List returned error: %v", err)
21 }
22
23 if len(emoji) == 0 {
24 t.Errorf("List returned no emojis")
25 }
26
27 if _, ok := emoji["+1"]; !ok {
28 t.Errorf("List missing '+1' emoji")
29 }
30 }
31
32 func TestAPIMeta(t *testing.T) {
33 meta, _, err := client.Meta.Get(context.Background())
34 if err != nil {
35 t.Fatalf("Get returned error: %v", err)
36 }
37
38 if len(meta.Hooks) == 0 {
39 t.Errorf("Get returned no hook addresses")
40 }
41
42 if len(meta.Git) == 0 {
43 t.Errorf("Get returned no git addresses")
44 }
45
46 if !*meta.VerifiablePasswordAuthentication {
47 t.Errorf("APIMeta VerifiablePasswordAuthentication is false")
48 }
49 }
50
51 func TestRateLimits(t *testing.T) {
52 limits, _, err := client.RateLimit.Get(context.Background())
53 if err != nil {
54 t.Fatalf("RateLimits returned error: %v", err)
55 }
56
57 // do some sanity checks
58 if limits.Core.Limit == 0 {
59 t.Errorf("RateLimits returned 0 core limit")
60 }
61
62 if limits.Core.Limit < limits.Core.Remaining {
63 t.Errorf("Core.Limits is less than Core.Remaining.")
64 }
65
66 if limits.Core.Reset.Time.Before(time.Now().Add(-1 * time.Minute)) {
67 t.Errorf("Core.Reset is more than 1 minute in the past; that doesn't seem right.")
68 }
69 }