Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions go/cmd/dolt/commands/sqlserver/minver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,10 @@ func validateMinVerFunc(field reflect.StructField, depth int) error {

minVerTag := field.Tag.Get("minver")
if minVerTag != "" {
if _, err := version.Encode(minVerTag); err != nil {
return fmt.Errorf("invalid minver tag on field %s '%s': %w", field.Name, minVerTag, err)
if minVerTag != "TBD" {
if _, err := version.Encode(minVerTag); err != nil {
return fmt.Errorf("invalid minver tag on field %s '%s': %w", field.Name, minVerTag, err)
}
}
hasMinVer = true
}
Expand Down Expand Up @@ -204,8 +206,16 @@ func TestMinVer(t *testing.T) {
err = structwalk.Walk(&nullableWithOmitEmpty{}, validateMinVerFunc)
require.NoError(t, err)

// validates the actual config struct
err = structwalk.Walk(&YAMLConfig{}, validateMinVerFunc)

// All new fields must:
// 1. Have a yaml tag with a name and omitempty
// 2. They must be nullable
// 3. They must have a minver tag with a value of TBD which will be replaced with the current version
// as part of the release process
//
// example:
// FieldName *string `yaml:"field_name,omitempty" minver:"TBD"`
require.NoError(t, err)
}

Expand Down Expand Up @@ -280,6 +290,8 @@ func TestMinVersionsValid(t *testing.T) {
if errors.Is(err, io.EOF) {
return fmt.Errorf("new field '%s' added", fi.String())
} else {
// You are seeing this error because a new config field was added that didn't meet the requirements.
// See the comment in "TestMinVer" which covers the requirements of new fields.
return fmt.Errorf("expected '%s' but got '%s'", prevFI.String(), fi.String())
}
})
Expand Down