Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move porcelain to stderr #124

Merged
merged 5 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
testsFolder = "tests"
)

func TestE2E(t *testing.T) {
func TestE2E(t *testing.T) { //nolint
t.Parallel()

// validate given binary path
Expand Down Expand Up @@ -75,6 +75,12 @@ func TestE2E(t *testing.T) {
stdout = re.ReplaceAllString(stdout, r.Replace)
}
}
if len(snapshot.ReplaceStdErrContent) > 0 {
for _, r := range snapshot.ReplaceStdErrContent {
var re = regexp.MustCompile(r.Search)
stderr = re.ReplaceAllString(stderr, r.Replace)
}
}

if snapshot.ExpectedStdOut != "" {
assert.Equal(t, snapshot.ExpectedStdOut, stdout)
Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/custom-config-file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ init_snapshot:
file_name: foo
content: shazam
expected_snapshot:
expected_stdout: |
expected_stderr: |
-*- teller: loaded variables for test using .custom-teller.yml -*-

[filesystem DYNAMIC-SHORT-PATH...tings/test/foo] FOO = sh*****

expected_stderr:
expected_stdout:
4 changes: 2 additions & 2 deletions e2e/tests/delete.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ expected_snapshot:
file_name: secret-c
content: shazam-1

expected_stdout: |
expected_stderr: |
Delete FOO (DYNAMIC-FULL-PATH/settings/test/foo) in filesystem: OK.
Delete BAR (DYNAMIC-FULL-PATH/settings/test/bar) in filesystem: OK.

expected_stderr:
expected_stdout:
4 changes: 2 additions & 2 deletions e2e/tests/put-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ expected_snapshot:
- path: settings/test/all
file_name: key-2
content: key-2-content
expected_stdout: |
expected_stderr: |
Synced filesystem (DYNAMIC-FULL-PATH/settings/test/all): OK.

expected_stderr:
expected_stdout:
4 changes: 2 additions & 2 deletions e2e/tests/put.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ expected_snapshot:
- path: settings/test/all
file_name: secret-c
content: shazam-1
expected_stdout: |
expected_stderr: |
Put BAR (DYNAMIC-FULL-PATH/settings/test/bar) in filesystem: OK.
Put FOO (DYNAMIC-FULL-PATH/settings/test/foo) in filesystem: OK.

expected_stderr:
expected_stdout:
3 changes: 1 addition & 2 deletions e2e/tests/scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ command: <binary-path> scan
config_file_name: .teller.yml
config_content: >
project: test

providers:
filesystem:
env_sync:
Expand Down Expand Up @@ -47,6 +47,5 @@ expected_stdout: |
[high] settings/test/foo (1,0): found match for filesystem/secret-b (sh*****)
[low] settings/test/foo (1,0): found match for filesystem/FOO (sh*****)
[medium] settings/test/foo (1,0): found match for filesystem/BAR (sh*****)

Scanning for 4 entries: found 10 matches in 1.000ms
expected_stderr:
4 changes: 2 additions & 2 deletions e2e/tests/show.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ init_snapshot:
file_name: secret-c
content: shazam-1
expected_snapshot:
expected_stdout: |
expected_stderr: |
-*- teller: loaded variables for test using .teller.yml -*-

[filesystem DYNAMIC-SHORT-PATH...tings/test/bar] BAR = sh*****
Expand All @@ -40,4 +40,4 @@ expected_stdout: |
[filesystem DYNAMIC-SHORT-PATH...tings/test/all] secret-b = sh*****
[filesystem DYNAMIC-SHORT-PATH...tings/test/all] secret-c = sh*****

expected_stderr:
expected_stdout:
21 changes: 11 additions & 10 deletions e2e/testutils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ import (
)

type SnapshotSuite struct {
Name string `yaml:"name,omitempty"`
Command string `yaml:"command,omitempty"`
ConfigFileName string `yaml:"config_file_name,omitempty"`
Config string `yaml:"config_content,omitempty"`
InitSnapshot []SnapshotData `yaml:"init_snapshot,omitempty"`
ExpectedSnapshot []SnapshotData `yaml:"expected_snapshot,omitempty"`
ExpectedStdOut string `yaml:"expected_stdout,omitempty"`
ExpectedStdErr string `yaml:"expected_stderr,omitempty"`
ReplaceStdOutContent []ReplaceStdOutContent `yaml:"replace_stdout_content,omitempty"`
Name string `yaml:"name,omitempty"`
Command string `yaml:"command,omitempty"`
ConfigFileName string `yaml:"config_file_name,omitempty"`
Config string `yaml:"config_content,omitempty"`
InitSnapshot []SnapshotData `yaml:"init_snapshot,omitempty"`
ExpectedSnapshot []SnapshotData `yaml:"expected_snapshot,omitempty"`
ExpectedStdOut string `yaml:"expected_stdout,omitempty"`
ExpectedStdErr string `yaml:"expected_stderr,omitempty"`
ReplaceStdOutContent []ReplaceStdContent `yaml:"replace_stdout_content,omitempty"`
ReplaceStdErrContent []ReplaceStdContent `yaml:"replace_stderr_content,omitempty"`
}

type SnapshotData struct {
Expand All @@ -28,7 +29,7 @@ type SnapshotData struct {
Content string `yaml:"content"`
}

type ReplaceStdOutContent struct {
type ReplaceStdContent struct {
Search string `yaml:"search"`
Replace string `yaml:"replace"`
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/teller.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func NewTeller(tlrfile *TellerFile, cmd []string, redact bool, logger logging.Lo
Cmd: cmd,
Providers: &BuiltinProviders{},
Populate: core.NewPopulate(tlrfile.Opts),
Porcelain: &Porcelain{Out: os.Stdout},
Porcelain: &Porcelain{Out: os.Stderr},
Templating: &Templating{},
Redactor: &Redactor{},
Logger: logger,
Expand Down