MCPcopy Index your code
hub / github.com/cli/cli / TestIsCI

Function TestIsCI

internal/ci/ci_test.go:9–32  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestIsCI(t *testing.T) {
10 tests := []struct {
11 name string
12 env map[string]string
13 want bool
14 }{
15 {name: "no CI env vars", env: map[string]string{}, want: false},
16 {name: "CI set", env: map[string]string{"CI": "true"}, want: true},
17 {name: "BUILD_NUMBER set", env: map[string]string{"BUILD_NUMBER": "42"}, want: true},
18 {name: "RUN_ID set", env: map[string]string{"RUN_ID": "abc"}, want: true},
19 {name: "CI empty string", env: map[string]string{"CI": ""}, want: false},
20 }
21 for _, tt := range tests {
22 t.Run(tt.name, func(t *testing.T) {
23 t.Setenv("CI", "")
24 t.Setenv("BUILD_NUMBER", "")
25 t.Setenv("RUN_ID", "")
26 for k, v := range tt.env {
27 t.Setenv(k, v)
28 }
29 assert.Equal(t, tt.want, IsCI())
30 })
31 }
32}
33
34func TestIsGitHubActions(t *testing.T) {
35 tests := []struct {

Callers

nothing calls this directly

Calls 3

IsCIFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected