(t *testing.T)
| 1519 | } |
| 1520 | |
| 1521 | func 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 | |
| 1539 | func TestFileWithDefault(t *testing.T) { |
| 1540 | type config struct { |
nothing calls this directly
no test coverage detected