Skip to content

Commit

Permalink
chore: add test to ensure requires works with dotenv
Browse files Browse the repository at this point in the history
closes go-task#1362

Signed-off-by: Yordis Prieto <[email protected]>
  • Loading branch information
yordis committed Oct 29, 2023
1 parent b681ef9 commit 003887a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
12 changes: 12 additions & 0 deletions task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1572,6 +1572,18 @@ func TestDotenvShouldAllowMissingEnv(t *testing.T) {
tt.Run(t)
}

func TestDotenvIsLoadBeforeRequiringVars(t *testing.T) {
tt := fileContentTest{
Dir: "testdata/dotenv/requiring_env",
Target: "default",
TrimSpace: false,
Files: map[string]string{
"include.txt": "REQUIRED_ENV='123' REQUIRED_TASK_ENV='456'\n",
},
}
tt.Run(t)
}

func TestDotenvHasLocalEnvInPath(t *testing.T) {
tt := fileContentTest{
Dir: "testdata/dotenv/local_env_in_path",
Expand Down
1 change: 1 addition & 0 deletions testdata/dotenv/requiring_env/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REQUIRED_ENV=123
1 change: 1 addition & 0 deletions testdata/dotenv/requiring_env/.task.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REQUIRED_TASK_ENV=456
13 changes: 13 additions & 0 deletions testdata/dotenv/requiring_env/Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3'

dotenv: ['.env']

tasks:
default:
dotenv: ['.task.env']
requires:
vars:
- REQUIRED_ENV
- REQUIRED_TASK_ENV
cmds:
- echo "REQUIRED_ENV='$REQUIRED_ENV' REQUIRED_TASK_ENV='$REQUIRED_TASK_ENV'" > include.txt

0 comments on commit 003887a

Please sign in to comment.