Debian Codegraph @

test/integration/audit_log_test.go

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