act/pkg/container/docker_run_test.go

35 lines
620 B
Go
Raw Normal View History

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)
}