MCPcopy Create free account
hub / github.com/github/gh-aw / TestIsRunningInCI

Function TestIsRunningInCI

pkg/cli/ci_test.go:9–87  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestIsRunningInCI(t *testing.T) {
10 tests := []struct {
11 name string
12 envVars map[string]string
13 expected bool
14 }{
15 {
16 name: "not running in CI - no env vars set",
17 envVars: map[string]string{},
18 expected: false,
19 },
20 {
21 name: "running in CI - CI env var set",
22 envVars: map[string]string{
23 "CI": "true",
24 },
25 expected: true,
26 },
27 {
28 name: "running in CI - CONTINUOUS_INTEGRATION env var set",
29 envVars: map[string]string{
30 "CONTINUOUS_INTEGRATION": "true",
31 },
32 expected: true,
33 },
34 {
35 name: "running in CI - GITHUB_ACTIONS env var set",
36 envVars: map[string]string{
37 "GITHUB_ACTIONS": "true",
38 },
39 expected: true,
40 },
41 {
42 name: "running in CI - multiple env vars set",
43 envVars: map[string]string{
44 "CI": "true",
45 "CONTINUOUS_INTEGRATION": "true",
46 "GITHUB_ACTIONS": "true",
47 },
48 expected: true,
49 },
50 {
51 name: "running in CI - CI env var set to empty string is still truthy",
52 envVars: map[string]string{
53 "CI": "",
54 },
55 expected: false,
56 },
57 {
58 name: "running in CI - other env vars don't affect result",
59 envVars: map[string]string{
60 "SOME_OTHER_VAR": "value",
61 "PATH": "/usr/bin",
62 },
63 expected: false,
64 },
65 }
66

Callers

nothing calls this directly

Calls 4

IsRunningInCIFunction · 0.85
SetenvMethod · 0.80
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected