diff --git a/go/vt/schema/ddl_strategy.go b/go/vt/schema/ddl_strategy.go index 32cad30764f..84dda605b8f 100644 --- a/go/vt/schema/ddl_strategy.go +++ b/go/vt/schema/ddl_strategy.go @@ -118,7 +118,7 @@ func ParseDDLStrategy(strategyVariable string) (*DDLStrategySetting, error) { } switch setting.Strategy { - case DDLStrategyVitess, DDLStrategyOnline: + case DDLStrategyVitess, DDLStrategyOnline, DDLStrategyMySQL, DDLStrategyDirect: if opts := setting.RuntimeOptions(); len(opts) > 0 { return nil, fmt.Errorf("invalid flags for vitess strategy: %s", strings.Join(opts, " ")) } diff --git a/go/vt/schema/ddl_strategy_test.go b/go/vt/schema/ddl_strategy_test.go index a853bdca539..ba7d029b8b7 100644 --- a/go/vt/schema/ddl_strategy_test.go +++ b/go/vt/schema/ddl_strategy_test.go @@ -41,19 +41,23 @@ func TestIsDirect(t *testing.T) { func TestIsCutOverThresholdFlag(t *testing.T) { tt := []struct { - s string - expect bool - val string - d time.Duration + s string + expect bool + expectError string + val string + d time.Duration }{ { - s: "something", + s: "something", + expectError: "invalid flags", }, { - s: "-cut-over-threshold", + s: "-cut-over-threshold", + expectError: "invalid flags", }, { - s: "--cut-over-threshold", + s: "--cut-over-threshold", + expectError: "invalid flags", }, { s: "--cut-over-threshold=", @@ -87,6 +91,11 @@ func TestIsCutOverThresholdFlag(t *testing.T) { for _, ts := range tt { t.Run(ts.s, func(t *testing.T) { setting, err := ParseDDLStrategy("online " + ts.s) + if ts.expectError != "" { + assert.ErrorContains(t, err, ts.expectError) + return + } + assert.NoError(t, err) val, isCutOver := isCutOverThresholdFlag(ts.s) @@ -104,19 +113,23 @@ func TestIsCutOverThresholdFlag(t *testing.T) { func TestIsExpireArtifactsFlag(t *testing.T) { tt := []struct { - s string - expect bool - val string - d time.Duration + s string + expect bool + expectError string + val string + d time.Duration }{ { - s: "something", + s: "something", + expectError: "invalid flags", }, { - s: "-retain-artifacts", + s: "-retain-artifacts", + expectError: "invalid flags", }, { - s: "--retain-artifacts", + s: "--retain-artifacts", + expectError: "invalid flags", }, { s: "--retain-artifacts=", @@ -150,6 +163,10 @@ func TestIsExpireArtifactsFlag(t *testing.T) { for _, ts := range tt { t.Run(ts.s, func(t *testing.T) { setting, err := ParseDDLStrategy("online " + ts.s) + if ts.expectError != "" { + assert.ErrorContains(t, err, ts.expectError) + return + } assert.NoError(t, err) val, isRetainArtifacts := isRetainArtifactsFlag(ts.s)