github.com/google/go-github/v49@v49.1.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 // +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.ListEmojis(context.Background()) 19 if err != nil { 20 t.Fatalf("ListEmojis returned error: %v", err) 21 } 22 23 if len(emoji) == 0 { 24 t.Errorf("ListEmojis returned no emojis") 25 } 26 27 if _, ok := emoji["+1"]; !ok { 28 t.Errorf("ListEmojis missing '+1' emoji") 29 } 30 } 31 32 func TestAPIMeta(t *testing.T) { 33 meta, _, err := client.APIMeta(context.Background()) 34 if err != nil { 35 t.Fatalf("APIMeta returned error: %v", err) 36 } 37 38 if len(meta.Hooks) == 0 { 39 t.Errorf("APIMeta returned no hook addresses") 40 } 41 42 if len(meta.Git) == 0 { 43 t.Errorf("APIMeta 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.RateLimits(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 } 70 71 func TestListServiceHooks(t *testing.T) { 72 hooks, _, err := client.ListServiceHooks(context.Background()) 73 if err != nil { 74 t.Fatalf("ListServiceHooks returned error: %v", err) 75 } 76 77 if len(hooks) == 0 { 78 t.Fatalf("ListServiceHooks returned no hooks") 79 } 80 }