act/pkg/container/docker_run_test.go
Ryan c2c8b525f8
Add reading environment from Docker image (#771)
* fix: read envvars from image definition

* fix: add test

* fix: sort slices

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-09-26 16:37:53 +00:00

34 lines
620 B
Go

package container
import (
"sort"
"testing"
"github.com/stretchr/testify/assert"
)
func TestMergeEnvFromImage(t *testing.T) {
inputEnv := []string{
"PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin",
"GOPATH=/root/go",
"GOOS=linux",
}
imageEnv := []string{
"PATH=/root/go/bin",
"GOPATH=/tmp",
"GOARCH=amd64",
}
merged := mergeEnvFromImage(inputEnv, imageEnv)
sort.Strings(merged)
expected := []string{
"PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:/root/go/bin",
"GOPATH=/root/go",
"GOOS=linux",
"GOARCH=amd64",
}
sort.Strings(expected)
assert.Equal(t, expected, merged)
}