-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
113 additions
and
13 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
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
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,46 @@ | ||
package render_test | ||
|
||
import ( | ||
"log" | ||
"os" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/jippi/dottie/pkg" | ||
"github.com/jippi/dottie/pkg/render" | ||
"github.com/sebdah/goldie/v2" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestFormatter(t *testing.T) { | ||
t.Parallel() | ||
|
||
g := goldie.New( | ||
t, | ||
goldie.WithFixtureDir("test-fixtures/formatter"), | ||
goldie.WithNameSuffix(".golden.env"), | ||
goldie.WithDiffEngine(goldie.ColoredDiff), | ||
goldie.WithTestNameForDir(false), | ||
) | ||
|
||
files, err := os.ReadDir("test-fixtures/formatter") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
for _, file := range files { | ||
switch { | ||
case strings.HasSuffix(file.Name(), ".input.env"): | ||
env, err := pkg.Load("test-fixtures/formatter/" + file.Name()) | ||
require.NoError(t, err) | ||
|
||
testName := strings.TrimSuffix(file.Name(), ".input.env") | ||
|
||
g.Assert(t, testName, []byte(render.NewFormatter(env))) | ||
|
||
case strings.HasSuffix(file.Name(), ".golden.env"): | ||
default: | ||
panic("unexpected file") | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
pkg/render/test-fixtures/formatter/comment-spacing.golden.env
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,5 @@ | ||
# My first key | ||
KEY=VALUE | ||
|
||
# My Second Key | ||
FOO=BAZ |
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,4 @@ | ||
# My first key | ||
KEY=VALUE | ||
# My Second Key | ||
FOO=BAZ |
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,17 @@ | ||
my_key="ok" | ||
|
||
# This is my favorite int | ||
# @dottie/validate number | ||
PORT="test" | ||
|
||
my_lol="ok" | ||
my_lol2="ok" | ||
|
||
################################################################################ | ||
# database | ||
################################################################################ | ||
|
||
# the hostname to the database | ||
DB_HOST="db" | ||
|
||
DB_PORT="${PORT}" |
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,12 @@ | ||
my_key="ok" | ||
# This is my favorite int | ||
# @dottie/validate number | ||
PORT="test" | ||
my_lol="ok" | ||
my_lol2="ok" | ||
################################################################################ | ||
# database | ||
################################################################################ | ||
# the hostname to the database | ||
DB_HOST="db" | ||
DB_PORT="${PORT}" |
Empty file.
Empty file.
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 @@ | ||
# Hello world |
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 @@ | ||
# Hello world |
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 @@ | ||
KEY=VALUE |
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 @@ | ||
KEY=VALUE |
2 changes: 2 additions & 0 deletions
2
pkg/render/test-fixtures/formatter/two-pairs-newlines.golden.env
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,2 @@ | ||
KEY=VALUE | ||
FOO=baz |
5 changes: 5 additions & 0 deletions
5
pkg/render/test-fixtures/formatter/two-pairs-newlines.input.env
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,5 @@ | ||
KEY=VALUE | ||
|
||
|
||
|
||
FOO=baz |
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,2 @@ | ||
KEY=VALUE | ||
FOO=baz |
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,2 @@ | ||
KEY=VALUE | ||
FOO=baz |