diff --git a/flyteplugins/go/tasks/plugins/testing/config.go b/flyteplugins/go/tasks/plugins/testing/config.go index c9f96bef29..9508bcafa7 100644 --- a/flyteplugins/go/tasks/plugins/testing/config.go +++ b/flyteplugins/go/tasks/plugins/testing/config.go @@ -19,5 +19,5 @@ var ( type Config struct { // SleepDuration indicates the amount of time before transitioning to success - SleepDuration flytestdconfig.Duration `json:"sleep-duration" pflag:"-,Indicates the amount of time before transitioning to success"` + SleepDuration flytestdconfig.Duration `json:"sleep-duration" pflag:",Indicates the amount of time before transitioning to success"` } diff --git a/flyteplugins/go/tasks/plugins/testing/config_flags.go b/flyteplugins/go/tasks/plugins/testing/config_flags.go index 999670c4d0..f4b2e60c7a 100755 --- a/flyteplugins/go/tasks/plugins/testing/config_flags.go +++ b/flyteplugins/go/tasks/plugins/testing/config_flags.go @@ -7,6 +7,8 @@ import ( "encoding/json" "reflect" + "fmt" + "github.com/spf13/pflag" ) @@ -48,5 +50,6 @@ func (Config) mustMarshalJSON(v json.Marshaler) string { // flags is json-name.json-sub-name... etc. func (cfg Config) GetPFlagSet(prefix string) *pflag.FlagSet { cmdFlags := pflag.NewFlagSet("Config", pflag.ExitOnError) + cmdFlags.String(fmt.Sprintf("%v%v", prefix, "sleep-duration"), defaultConfig.SleepDuration.String(), "Indicates the amount of time before transitioning to success") return cmdFlags } diff --git a/flyteplugins/go/tasks/plugins/testing/config_flags_test.go b/flyteplugins/go/tasks/plugins/testing/config_flags_test.go index 4bd7b73d1f..023e8986e0 100755 --- a/flyteplugins/go/tasks/plugins/testing/config_flags_test.go +++ b/flyteplugins/go/tasks/plugins/testing/config_flags_test.go @@ -99,4 +99,18 @@ func TestConfig_SetFlags(t *testing.T) { cmdFlags := actual.GetPFlagSet("") assert.True(t, cmdFlags.HasFlags()) + t.Run("Test_sleep-duration", func(t *testing.T) { + + t.Run("Override", func(t *testing.T) { + testValue := defaultConfig.SleepDuration.String() + + cmdFlags.Set("sleep-duration", testValue) + if vString, err := cmdFlags.GetString("sleep-duration"); err == nil { + testDecodeJson_Config(t, fmt.Sprintf("%v", vString), &actual.SleepDuration) + + } else { + assert.FailNow(t, err.Error()) + } + }) + }) }