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