File: audit_log_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 (33 lines) | stat: -rw-r--r-- 863 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
// Copyright 2021 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"
)

// TestOrganizationAuditLog test that the client can read an org's audit log
// Note: Org must be part of an enterprise
// Test requires auth - set env var GITHUB_AUTH_TOKEN
func TestOrganizationAuditLog(t *testing.T) {
	org := "example_org"
	entries, _, err := client.Organizations.GetAuditLog(context.Background(), org, nil)
	if err != nil {
		t.Fatalf("Organizations.GetAuditLog returned error: %v", err)
	}

	if len(entries) == 0 {
		t.Errorf("No AuditLog events returned for org")
	}

	for _, e := range entries {
		t.Log(e.GetAction(), e.GetActor(), e.GetTimestamp(), e.GetUser())
	}
}