forked from toolshed/abra
fix: fix: trim comments that are not modifers
See coop-cloud/organising#505
This commit is contained in:
@ -70,7 +70,7 @@ func TestGetAllFilesInDirectory(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestReadEnv(t *testing.T) {
|
||||
env, err := config.ReadEnv(ExpectedAppFile.Path)
|
||||
env, err := config.ReadEnv(ExpectedAppFile.Path, config.ReadEnvOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -123,7 +123,7 @@ func TestCheckEnv(t *testing.T) {
|
||||
}
|
||||
|
||||
envSamplePath := path.Join(config.RECIPES_DIR, r.Name, ".env.sample")
|
||||
envSample, err := config.ReadEnv(envSamplePath)
|
||||
envSample, err := config.ReadEnv(envSamplePath, config.ReadEnvOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -157,7 +157,7 @@ func TestCheckEnvError(t *testing.T) {
|
||||
}
|
||||
|
||||
envSamplePath := path.Join(config.RECIPES_DIR, r.Name, ".env.sample")
|
||||
envSample, err := config.ReadEnv(envSamplePath)
|
||||
envSample, err := config.ReadEnv(envSamplePath, config.ReadEnvOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -203,7 +203,7 @@ func TestEnvVarCommentsRemoved(t *testing.T) {
|
||||
}
|
||||
|
||||
envSamplePath := path.Join(config.RECIPES_DIR, r.Name, ".env.sample")
|
||||
envSample, err := config.ReadEnv(envSamplePath)
|
||||
envSample, err := config.ReadEnv(envSamplePath, config.ReadEnvOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -216,4 +216,31 @@ func TestEnvVarCommentsRemoved(t *testing.T) {
|
||||
if strings.Contains(envVar, "should be removed") {
|
||||
t.Fatalf("comment from '%s' should be removed", envVar)
|
||||
}
|
||||
|
||||
envVar, exists = envSample["SECRET_TEST_PASS_TWO_VERSION"]
|
||||
if !exists {
|
||||
t.Fatal("WITH_COMMENT env var should be present in .env.sample")
|
||||
}
|
||||
|
||||
if strings.Contains(envVar, "length") {
|
||||
t.Fatal("comment from env var SECRET_TEST_PASS_TWO_VERSION should have been removed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnvVarModifiersIncluded(t *testing.T) {
|
||||
offline := true
|
||||
r, err := recipe.Get("abra-test-recipe", offline)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
envSamplePath := path.Join(config.RECIPES_DIR, r.Name, ".env.sample")
|
||||
envSample, err := config.ReadEnv(envSamplePath, config.ReadEnvOptions{IncludeModifiers: true})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if !strings.Contains(envSample["SECRET_TEST_PASS_TWO_VERSION"], "length") {
|
||||
t.Fatal("comment from env var SECRET_TEST_PASS_TWO_VERSION should not be removed")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user