MCPcopy Create free account
hub / github.com/caarlos0/env / TestFileBadFile

Function TestFileBadFile

env_test.go:1521–1537  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1519}
1520
1521func TestFileBadFile(t *testing.T) {
1522 type config struct {
1523 SecretKey string `env:"SECRET_KEY,file"`
1524 }
1525
1526 filename := "not-a-real-file"
1527 t.Setenv("SECRET_KEY", filename)
1528
1529 oserr := "no such file or directory"
1530 if runtime.GOOS == "windows" {
1531 oserr = "The system cannot find the file specified."
1532 }
1533
1534 err := Parse(&config{})
1535 isErrorWithMessage(t, err, fmt.Sprintf("env: could not load content of file %q from variable SECRET_KEY: open %s: %s", filename, filename, oserr))
1536 isTrue(t, errors.Is(err, LoadFileContentError{}))
1537}
1538
1539func TestFileWithDefault(t *testing.T) {
1540 type config struct {

Callers

nothing calls this directly

Calls 4

ParseFunction · 0.85
isErrorWithMessageFunction · 0.85
isTrueFunction · 0.85
IsMethod · 0.80

Tested by

no test coverage detected