-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from leapkit/fix-envor-multiple-equals
fix: fixing Envor variables with multiple equals
- Loading branch information
Showing
2 changed files
with
72 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package envor | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestParseVars(t *testing.T) { | ||
|
||
t.Run("simple one", func(t *testing.T) { | ||
r := strings.NewReader("KEY=value\n") | ||
vars := parseVars(r) | ||
|
||
if vars["KEY"] != "value" { | ||
t.Errorf("Expected value to be 'value', got %s", vars["KEY"]) | ||
} | ||
}) | ||
|
||
t.Run("multiple", func(t *testing.T) { | ||
vars := parseVars(strings.NewReader(` | ||
KEY=value | ||
KEY2=value | ||
`)) | ||
|
||
if vars["KEY"] != "value" { | ||
t.Errorf("Expected value to be 'value', got %s", vars["KEY"]) | ||
} | ||
|
||
if vars["KEY2"] != "value" { | ||
t.Errorf("Expected value to be 'value', got %s", vars["KEY"]) | ||
} | ||
}) | ||
|
||
t.Run("quotes", func(t *testing.T) { | ||
vars := parseVars(strings.NewReader(` | ||
KEY="value" | ||
`)) | ||
|
||
if vars["KEY"] != "value" { | ||
t.Errorf("Expected value to be 'value', got %s", vars["KEY"]) | ||
} | ||
}) | ||
|
||
t.Run("multiple equals sign", func(t *testing.T) { | ||
vars := parseVars(strings.NewReader(` | ||
KEY="value=with=equals" | ||
`)) | ||
|
||
if vars["KEY"] != "value=with=equals" { | ||
t.Errorf("Expected value to be 'value=with=equals', got %s", vars["KEY"]) | ||
} | ||
}) | ||
|
||
} |