Skip to content

Commit

Permalink
Merge cbc8c7c into de19a6a
Browse files Browse the repository at this point in the history
  • Loading branch information
codebien committed Oct 12, 2023
2 parents de19a6a + cbc8c7c commit 3510846
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 42 deletions.
13 changes: 3 additions & 10 deletions output/csv/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ import (

// Config is the config for the csv output
type Config struct {
// Samples.
FileName null.String `json:"file_name" envconfig:"K6_CSV_FILENAME"`
SaveInterval types.NullDuration `json:"save_interval" envconfig:"K6_CSV_SAVE_INTERVAL"`
TimeFormat null.String `json:"time_format" envconfig:"K6_CSV_TIME_FORMAT"`
FileName null.String `json:"fileName" envconfig:"K6_CSV_FILENAME"`
SaveInterval types.NullDuration `json:"saveInterval" envconfig:"K6_CSV_SAVE_INTERVAL"`
TimeFormat null.String `json:"timeFormat" envconfig:"K6_CSV_TIME_FORMAT"`
}

// TimeFormat custom enum type
Expand Down Expand Up @@ -75,17 +74,11 @@ func ParseArg(arg string, logger logrus.FieldLogger) (Config, error) {
return c, fmt.Errorf("couldn't parse %q as argument for csv output", arg)
}
switch r[0] {
case "save_interval":
logger.Warnf("CSV output argument '%s' is deprecated, please use 'saveInterval' instead.", r[0])
fallthrough
case "saveInterval":
err := c.SaveInterval.UnmarshalText([]byte(r[1]))
if err != nil {
return c, err
}
case "file_name":
logger.Warnf("CSV output argument '%s' is deprecated, please use 'fileName' instead.", r[0])
fallthrough
case "fileName":
c.FileName = null.StringFrom(r[1])
case "timeFormat":
Expand Down
33 changes: 1 addition & 32 deletions output/csv/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,45 +80,14 @@ func TestParseArg(t *testing.T) {
TimeFormat: null.NewString("unix", false),
},
},
"save_interval=5s": {
config: Config{
FileName: null.NewString("file.csv", false),
SaveInterval: types.NullDurationFrom(5 * time.Second),
TimeFormat: null.NewString("unix", false),
},
expectedLogEntries: []string{
"CSV output argument 'save_interval' is deprecated, please use 'saveInterval' instead.",
},
},
"saveInterval=5s": {
config: Config{
FileName: null.NewString("file.csv", false),
SaveInterval: types.NullDurationFrom(5 * time.Second),
TimeFormat: null.NewString("unix", false),
},
},
"file_name=test.csv,save_interval=5s": {
config: Config{
FileName: null.StringFrom("test.csv"),
SaveInterval: types.NullDurationFrom(5 * time.Second),
TimeFormat: null.NewString("unix", false),
},
expectedLogEntries: []string{
"CSV output argument 'file_name' is deprecated, please use 'fileName' instead.",
"CSV output argument 'save_interval' is deprecated, please use 'saveInterval' instead.",
},
},
"fileName=test.csv,save_interval=5s": {
config: Config{
FileName: null.StringFrom("test.csv"),
SaveInterval: types.NullDurationFrom(5 * time.Second),
TimeFormat: null.NewString("unix", false),
},
expectedLogEntries: []string{
"CSV output argument 'save_interval' is deprecated, please use 'saveInterval' instead.",
},
},
"filename=test.csv,save_interval=5s": {
"filename=test.csv,saveInterval=5s": {
expectedErr: true,
},
"fileName=test.csv,timeFormat=rfc3339": {
Expand Down

0 comments on commit 3510846

Please sign in to comment.