File: misc_test.go

package info (click to toggle)
golang-github-google-go-github 60.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,700 kB
  • sloc: sh: 111; makefile: 5
file content (69 lines) | stat: -rw-r--r-- 1,531 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright 2014 The go-github AUTHORS. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build integration
// +build integration

package integration

import (
	"context"
	"testing"
	"time"
)

func TestEmojis(t *testing.T) {
	emoji, _, err := client.Emojis.List(context.Background())
	if err != nil {
		t.Fatalf("List returned error: %v", err)
	}

	if len(emoji) == 0 {
		t.Errorf("List returned no emojis")
	}

	if _, ok := emoji["+1"]; !ok {
		t.Errorf("List missing '+1' emoji")
	}
}

func TestAPIMeta(t *testing.T) {
	meta, _, err := client.Meta.Get(context.Background())
	if err != nil {
		t.Fatalf("Get returned error: %v", err)
	}

	if len(meta.Hooks) == 0 {
		t.Errorf("Get returned no hook addresses")
	}

	if len(meta.Git) == 0 {
		t.Errorf("Get returned no git addresses")
	}

	if !*meta.VerifiablePasswordAuthentication {
		t.Errorf("APIMeta VerifiablePasswordAuthentication is false")
	}
}

func TestRateLimits(t *testing.T) {
	limits, _, err := client.RateLimit.Get(context.Background())
	if err != nil {
		t.Fatalf("RateLimits returned error: %v", err)
	}

	// do some sanity checks
	if limits.Core.Limit == 0 {
		t.Errorf("RateLimits returned 0 core limit")
	}

	if limits.Core.Limit < limits.Core.Remaining {
		t.Errorf("Core.Limits is less than Core.Remaining.")
	}

	if limits.Core.Reset.Time.Before(time.Now().Add(-1 * time.Minute)) {
		t.Errorf("Core.Reset is more than 1 minute in the past; that doesn't seem right.")
	}
}