Skip to content

Commit eecf6b1

Browse files
authored
tests: golden regex replace only actual output (#2747)
1 parent 2151cb4 commit eecf6b1

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

β€Žinternal/core/testing.goβ€Ž

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -618,10 +618,8 @@ func TestCheckGoldenAndReplacePatterns(replacements ...GoldenReplacement) TestCh
618618

619619
expected, err := os.ReadFile(goldenPath)
620620
require.NoError(t, err, "expected to find golden file %s", goldenPath)
621-
expectedString, expectedReplaceErr := goldenReplacePatterns(string(expected), replacements...)
622-
assert.Equal(t, expectedString, actual)
621+
assert.Equal(t, string(expected), actual)
623622
assert.Nil(t, actualReplaceErr, "failed to match test output with regexes")
624-
assert.Nil(t, expectedReplaceErr, "failed to match stored golden with regexes")
625623
}
626624
}
627625

β€Žinternal/namespaces/config/commands_test.goβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ func Test_ConfigInfoCommand(t *testing.T) {
260260
// replace ConfigPath lines with "/tmp/scw/.config/scw/config.yaml"
261261
configPathReplacements := []core.GoldenReplacement{
262262
{
263-
Pattern: regexp.MustCompile(`(ConfigPath\s).*`),
263+
Pattern: regexp.MustCompile(`(ConfigPath\s+).*`),
264264
Replacement: "$1/tmp/scw/.config/scw/config.yaml",
265265
},
266266
{

β€Žinternal/namespaces/config/testdata/test-config-info-command-profile.goldenβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
22
🟩🟩🟩 STDOUT️ 🟩🟩🟩️
3-
ConfigPath /tmp/scw3107607218/.config/scw/config.yaml
3+
ConfigPath /tmp/scw/.config/scw/config.yaml
44
ProfileName p1
55
Profile.access-key SCWP1XXXXXXXXXXXXXXX
66
Profile.api-url https://p1-mock-api-url.com
@@ -11,7 +11,7 @@ Profile.insecure true
1111
Profile.secret-key 11111111-1111-1111-1111-111111111111
1212
🟩🟩🟩 JSON STDOUT 🟩🟩🟩
1313
{
14-
"ConfigPath": "/tmp/scw3107607218/.config/scw/config.yaml",
14+
"ConfigPath": "/tmp/scw/.config/scw/config.yaml",
1515
"ProfileName": "p1",
1616
"Profile": {
1717
"access-key": "SCWP1XXXXXXXXXXXXXXX",

β€Žinternal/namespaces/config/testdata/test-config-info-command-simple.goldenβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
22
🟩🟩🟩 STDOUT️ 🟩🟩🟩️
3-
ConfigPath /tmp/scw1635042996/.config/scw/config.yaml
3+
ConfigPath /tmp/scw/.config/scw/config.yaml
44
ProfileName default
55
Profile.access-key SCWXXXXXXXXXXXXXXXXX
66
Profile.default-organization-id 11111111-1111-1111-1111-111111111111
@@ -11,7 +11,7 @@ Profile.secret-key 11111111-1111-1111-1111-111111111111
1111
Profile.send-telemetry true
1212
🟩🟩🟩 JSON STDOUT 🟩🟩🟩
1313
{
14-
"ConfigPath": "/tmp/scw1635042996/.config/scw/config.yaml",
14+
"ConfigPath": "/tmp/scw/.config/scw/config.yaml",
1515
"ProfileName": "default",
1616
"Profile": {
1717
"access-key": "SCWXXXXXXXXXXXXXXXXX",

0 commit comments

Comments
Β (0)