Skip to content

Commit f7f6865

Browse files
authored
move porcelain to stderr (#124)
move porcelain to stderr
1 parent edde1ee commit f7f6865

9 files changed

Lines changed: 30 additions & 24 deletions

File tree

e2e/e2e_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const (
2323
testsFolder = "tests"
2424
)
2525

26-
func TestE2E(t *testing.T) {
26+
func TestE2E(t *testing.T) { //nolint
2727
t.Parallel()
2828

2929
// validate given binary path
@@ -75,6 +75,12 @@ func TestE2E(t *testing.T) {
7575
stdout = re.ReplaceAllString(stdout, r.Replace)
7676
}
7777
}
78+
if len(snapshot.ReplaceStdErrContent) > 0 {
79+
for _, r := range snapshot.ReplaceStdErrContent {
80+
var re = regexp.MustCompile(r.Search)
81+
stderr = re.ReplaceAllString(stderr, r.Replace)
82+
}
83+
}
7884

7985
if snapshot.ExpectedStdOut != "" {
8086
assert.Equal(t, snapshot.ExpectedStdOut, stdout)

e2e/tests/custom-config-file.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ init_snapshot:
1515
file_name: foo
1616
content: shazam
1717
expected_snapshot:
18-
expected_stdout: |
18+
expected_stderr: |
1919
-*- teller: loaded variables for test using .custom-teller.yml -*-
2020
2121
[filesystem DYNAMIC-SHORT-PATH...tings/test/foo] FOO = sh*****
2222
23-
expected_stderr:
23+
expected_stdout:

e2e/tests/delete.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ expected_snapshot:
4141
file_name: secret-c
4242
content: shazam-1
4343

44-
expected_stdout: |
44+
expected_stderr: |
4545
Delete FOO (DYNAMIC-FULL-PATH/settings/test/foo) in filesystem: OK.
4646
Delete BAR (DYNAMIC-FULL-PATH/settings/test/bar) in filesystem: OK.
4747
48-
expected_stderr:
48+
expected_stdout:

e2e/tests/put-sync.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ expected_snapshot:
5252
- path: settings/test/all
5353
file_name: key-2
5454
content: key-2-content
55-
expected_stdout: |
55+
expected_stderr: |
5656
Synced filesystem (DYNAMIC-FULL-PATH/settings/test/all): OK.
5757
58-
expected_stderr:
58+
expected_stdout:

e2e/tests/put.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ expected_snapshot:
4646
- path: settings/test/all
4747
file_name: secret-c
4848
content: shazam-1
49-
expected_stdout: |
49+
expected_stderr: |
5050
Put BAR (DYNAMIC-FULL-PATH/settings/test/bar) in filesystem: OK.
5151
Put FOO (DYNAMIC-FULL-PATH/settings/test/foo) in filesystem: OK.
5252
53-
expected_stderr:
53+
expected_stdout:

e2e/tests/scan.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ command: <binary-path> scan
44
config_file_name: .teller.yml
55
config_content: >
66
project: test
7-
7+
88
providers:
99
filesystem:
1010
env_sync:
@@ -47,6 +47,5 @@ expected_stdout: |
4747
[high] settings/test/foo (1,0): found match for filesystem/secret-b (sh*****)
4848
[low] settings/test/foo (1,0): found match for filesystem/FOO (sh*****)
4949
[medium] settings/test/foo (1,0): found match for filesystem/BAR (sh*****)
50-
5150
Scanning for 4 entries: found 10 matches in 1.000ms
5251
expected_stderr:

e2e/tests/show.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ init_snapshot:
3131
file_name: secret-c
3232
content: shazam-1
3333
expected_snapshot:
34-
expected_stdout: |
34+
expected_stderr: |
3535
-*- teller: loaded variables for test using .teller.yml -*-
3636
3737
[filesystem DYNAMIC-SHORT-PATH...tings/test/bar] BAR = sh*****
@@ -40,4 +40,4 @@ expected_stdout: |
4040
[filesystem DYNAMIC-SHORT-PATH...tings/test/all] secret-b = sh*****
4141
[filesystem DYNAMIC-SHORT-PATH...tings/test/all] secret-c = sh*****
4242
43-
expected_stderr:
43+
expected_stdout:

e2e/testutils/config.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ import (
1111
)
1212

1313
type SnapshotSuite struct {
14-
Name string `yaml:"name,omitempty"`
15-
Command string `yaml:"command,omitempty"`
16-
ConfigFileName string `yaml:"config_file_name,omitempty"`
17-
Config string `yaml:"config_content,omitempty"`
18-
InitSnapshot []SnapshotData `yaml:"init_snapshot,omitempty"`
19-
ExpectedSnapshot []SnapshotData `yaml:"expected_snapshot,omitempty"`
20-
ExpectedStdOut string `yaml:"expected_stdout,omitempty"`
21-
ExpectedStdErr string `yaml:"expected_stderr,omitempty"`
22-
ReplaceStdOutContent []ReplaceStdOutContent `yaml:"replace_stdout_content,omitempty"`
14+
Name string `yaml:"name,omitempty"`
15+
Command string `yaml:"command,omitempty"`
16+
ConfigFileName string `yaml:"config_file_name,omitempty"`
17+
Config string `yaml:"config_content,omitempty"`
18+
InitSnapshot []SnapshotData `yaml:"init_snapshot,omitempty"`
19+
ExpectedSnapshot []SnapshotData `yaml:"expected_snapshot,omitempty"`
20+
ExpectedStdOut string `yaml:"expected_stdout,omitempty"`
21+
ExpectedStdErr string `yaml:"expected_stderr,omitempty"`
22+
ReplaceStdOutContent []ReplaceStdContent `yaml:"replace_stdout_content,omitempty"`
23+
ReplaceStdErrContent []ReplaceStdContent `yaml:"replace_stderr_content,omitempty"`
2324
}
2425

2526
type SnapshotData struct {
@@ -28,7 +29,7 @@ type SnapshotData struct {
2829
Content string `yaml:"content"`
2930
}
3031

31-
type ReplaceStdOutContent struct {
32+
type ReplaceStdContent struct {
3233
Search string `yaml:"search"`
3334
Replace string `yaml:"replace"`
3435
}

pkg/teller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func NewTeller(tlrfile *TellerFile, cmd []string, redact bool, logger logging.Lo
4949
Cmd: cmd,
5050
Providers: &BuiltinProviders{},
5151
Populate: core.NewPopulate(tlrfile.Opts),
52-
Porcelain: &Porcelain{Out: os.Stdout},
52+
Porcelain: &Porcelain{Out: os.Stderr},
5353
Templating: &Templating{},
5454
Redactor: &Redactor{},
5555
Logger: logger,

0 commit comments

Comments
 (0)