MCPcopy
hub / github.com/nektos/act / TestParseEnvfileVariables

Function TestParseEnvfileVariables

pkg/container/docker_cli_test.go:947–971  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

945}
946
947func TestParseEnvfileVariables(t *testing.T) {
948 e := "open nonexistent: no such file or directory"
949 if runtime.GOOS == "windows" {
950 e = "open nonexistent: The system cannot find the file specified."
951 }
952 // env ko
953 if _, _, _, err := parseRun([]string{"--env-file=nonexistent", "img", "cmd"}); err == nil || err.Error() != e {
954 t.Fatalf("Expected an error with message '%s', got %v", e, err)
955 }
956 // env ok
957 config, _, _, err := parseRun([]string{"--env-file=testdata/valid.env", "img", "cmd"})
958 if err != nil {
959 t.Fatal(err)
960 }
961 if len(config.Env) != 1 || config.Env[0] != "ENV1=value1" {
962 t.Fatalf("Expected a config with [ENV1=value1], got %v", config.Env)
963 }
964 config, _, _, err = parseRun([]string{"--env-file=testdata/valid.env", "--env=ENV2=value2", "img", "cmd"})
965 if err != nil {
966 t.Fatal(err)
967 }
968 if len(config.Env) != 2 || config.Env[0] != "ENV1=value1" || config.Env[1] != "ENV2=value2" {
969 t.Fatalf("Expected a config with [ENV1=value1 ENV2=value2], got %v", config.Env)
970 }
971}
972
973func TestParseEnvfileVariablesWithBOMUnicode(t *testing.T) {
974 // UTF8 with BOM

Callers

nothing calls this directly

Calls 2

parseRunFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…