forked from CivicActions/bowline
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for multiple compose files using env vars CivicActions#90
- Loading branch information
David Numan
committed
May 26, 2020
1 parent
fd9aee2
commit e2004db
Showing
3 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestParseComposeFilesEnv(t *testing.T) { | ||
var testSets = []struct { | ||
name string | ||
envVars map[string]string | ||
want string | ||
}{ | ||
{"BOWLINE_COMPOSE_FILE one file", | ||
map[string]string{"BOWLINE_COMPOSE_FILE": "docker-compose.yml"}, "docker-compose.yml"}, | ||
{"BOWLINE_COMPOSE_FILE two files", | ||
map[string]string{"BOWLINE_COMPOSE_FILE": "docker-compose.yml:file2"}, "docker-compose.yml:file2"}, | ||
{"COMPOSE_FILE", | ||
map[string]string{"COMPOSE_FILE": "docker-compose.yml"}, "docker-compose.yml"}, | ||
{"No var set", | ||
map[string]string{}, "docker-compose.yml"}, | ||
{"Both vars set", | ||
map[string]string{"COMPOSE_FILE": "wrong value", "BOWLINE_COMPOSE_FILE": "correct"}, "correct"}, | ||
} | ||
|
||
for _, ts := range testSets { | ||
ts := ts | ||
t.Run(ts.name, func(t *testing.T) { | ||
os.Unsetenv("BOWLINE_COMPOSE_FILE") | ||
os.Unsetenv("COMPOSE_FILE") | ||
for key, val := range ts.envVars { | ||
os.Setenv(key, val) | ||
} | ||
composeFileString, _ := parseComposeFilesEnv() | ||
if composeFileString != ts.want { | ||
t.Errorf("Unexpected results: %s does not match %s", composeFileString, ts.want) | ||
} | ||
}) | ||
} | ||
|
||
} |