github.com/google/go-github/v68@v68.0.0/test/integration/audit_log_test.go (about) 1 // Copyright 2021 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 ) 14 15 // TestOrganizationAuditLog test that the client can read an org's audit log. 16 // Note: Org must be part of an enterprise. 17 // Test requires auth - set env var GITHUB_AUTH_TOKEN. 18 func TestOrganizationAuditLog(t *testing.T) { 19 org := "example_org" 20 entries, _, err := client.Organizations.GetAuditLog(context.Background(), org, nil) 21 if err != nil { 22 t.Fatalf("Organizations.GetAuditLog returned error: %v", err) 23 } 24 25 if len(entries) == 0 { 26 t.Errorf("No AuditLog events returned for org") 27 } 28 29 for _, e := range entries { 30 t.Log(e.GetAction(), e.GetActor(), e.GetTimestamp(), e.GetUser()) 31 } 32 }