File tree 3 files changed +16
-2
lines changed
3 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,11 @@ func BashTestFile(
65
65
script string ,
66
66
bashConfig BashConfig ,
67
67
) {
68
- goldenFilePath := script + goldenExtension
68
+ ext := goldenExtension
69
+ if bashConfig .GoldenExtension != "" {
70
+ ext = bashConfig .GoldenExtension
71
+ }
72
+ goldenFilePath := script + ext
69
73
// Function run by the test.
70
74
f := func (t * testing.T ) {
71
75
// Make script path absolute to avoid issues with custom working
Original file line number Diff line number Diff line change @@ -27,6 +27,9 @@ type Config struct {
27
27
CompareConfig CompareConfig
28
28
// OutputProcessConfig defines how to process the output before comparison.
29
29
OutputProcessConfig OutputProcessConfig
30
+ // GoldenExtension is the file extension to use for the golden file. If not
31
+ // provided, then the default extension (.golden) is used.
32
+ GoldenExtension string
30
33
// SkipGoldenComparison skips the comparison against the golden file.
31
34
SkipGoldenComparison bool
32
35
// ExitCode defines the expected exit code of the command.
@@ -68,6 +71,9 @@ type BashConfig struct {
68
71
DisplayStderr bool
69
72
// OutputProcessConfig defines how to process the output before comparison.
70
73
OutputProcessConfig OutputProcessConfig
74
+ // GoldenExtension is the file extension to use for the golden file. If not
75
+ // provided, then the default extension (.golden) is used.
76
+ GoldenExtension string
71
77
// Envs specifies the environment variables to set for execution.
72
78
Envs [][2 ]string
73
79
// PostProcessFunctions defines a list of functions to be executed after the bash
Original file line number Diff line number Diff line change @@ -156,7 +156,11 @@ func comparison(
156
156
) {
157
157
var err error
158
158
159
- goldenPath := inputPath + goldenExtension
159
+ ext := goldenExtension
160
+ if config .GoldenExtension != "" {
161
+ ext = config .GoldenExtension
162
+ }
163
+ goldenPath := inputPath + ext
160
164
if config .OutputProcessConfig .RelativeDestination != "" {
161
165
goldenPath = filepath .Join (
162
166
config .OutputProcessConfig .RelativeDestination ,
You can’t perform that action at this time.
0 commit comments