Skip to content
quarry Artifact [1e69f321db]
Login

Artifact [1e69f321db]

Artifact 1e69f321db9553cccab10e83882c66dbc24317a9ba61681d07419d12d6702ee2:


package runner

import (
	"context"
	"strings"
	"testing"
)

// A task run as the runner itself is told it runs under CI, as a job
// under a job user already is (jobEnv): tests that need a tool CI
// provides fail there rather than skip. A task's own env still wins.
func TestPlainStarterSaysCI(t *testing.T) {
	t.Setenv("CI", "")
	for _, c := range []struct {
		env  map[string]string
		want string
	}{{nil, "true"}, {map[string]string{"CI": "false"}, "false"}} {
		out, err := plainStarter(context.Background(), t.TempDir(), []string{"sh", "-c", "printf %s \"$CI\""}, c.env).Output()
		if err != nil {
			t.Fatal(err)
		}
		if got := strings.TrimSpace(string(out)); got != c.want {
			t.Errorf("FAIL: CI=%q with task env %v, want %q", got, c.env, c.want)
		} else {
			t.Logf("ok: CI=%s with task env %v", got, c.env)
		}
	}
}