Skip to content

Commit

Permalink
more tests for print
Browse files Browse the repository at this point in the history
  • Loading branch information
jippi committed Feb 15, 2024
1 parent aa6187f commit 99b261f
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/print/prin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ import (
func TestCommand(t *testing.T) {
t.Parallel()

test_helpers.RunFilebasedCommandTests(t, 0, "print")
test_helpers.RunFilebasedCommandTests(t, test_helpers.SkipEnvCopy, "print")
}
2 changes: 1 addition & 1 deletion cmd/print/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func NewCommand() *cobra.Command {
return err
}

fmt.Println(render.NewRenderer(*settings).Statement(env).String())
fmt.Fprintln(cmd.OutOrStdout(), render.NewRenderer(*settings).Statement(env).String())

return nil
},
Expand Down
1 change: 1 addition & 0 deletions cmd/print/tests/empty.command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--no-color
Empty file removed cmd/print/tests/empty/env.golden
Empty file.
2 changes: 2 additions & 0 deletions cmd/print/tests/empty/stdout.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@


1 change: 1 addition & 0 deletions cmd/print/tests/full.command.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
--pretty
--no-color
31 changes: 31 additions & 0 deletions cmd/print/tests/full/stdout.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
################################################################################
# My first group
################################################################################

KEY_A="I'm key A"

# Comment for KEY_B
KEY_B="I'm key B"

KEY_C="I'm key C"

################################################################################
# My Second group
################################################################################

GROUP_TWO_A="hello"

# This is nice, format me
GROUP_TWO_A="WORLD"

################################################################################
# My Third group
################################################################################

# A Comment

# Another comment
# with two lines

SECRET=KEY

1 change: 1 addition & 0 deletions cmd/print/tests/simple-pretty.command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--no-color
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
KEY_A="I'm key A"
# Comment for KEY_B
KEY_B="I'm key B"
KEY_C="I'm key C"

1 change: 1 addition & 0 deletions cmd/print/tests/simple.command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--no-color
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
KEY_A="I'm key A"

# Comment for KEY_B
KEY_B="I'm key B"

KEY_C="I'm key C"

3 changes: 3 additions & 0 deletions cmd/print/tests/specific-group.command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--no-color
--group
my-first-group
File renamed without changes.
4 changes: 4 additions & 0 deletions cmd/print/tests/specific-group/stdout.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
KEY_A="I'm key A"
KEY_B="I'm key B"
KEY_C="I'm key C"

0 comments on commit 99b261f

Please sign in to comment.