Repository: dolthub/dolt
File: go/libraries/doltcore/env/actions/test_table_helpers.go (Go)

Code before:
		}
	case ">=":
		if realValue.LessThan(expectedValue) {
			return fmt.Sprintf("Assertion failed: %s greater than or equal to %v, got %v", assertionType, expectedValue, realValue)
		}
	default:
		return fmt.Sprintf("%s is not a valid assertion type", comparison)
	}
	return ""
}

// compareNullValue is a function used for comparing a null value.
// It takes in a comparison string from one of: "==", "!="
// It returns a string. The string is empty if the assertion passed, or has a message explaining the failure otherwise
func compareNullValue(comparison string, actualValue interface{}, assertionType string) string {
	switch comparison {
	case "==":
		if actualValue != nil {
			return fmt.Sprintf("Assertion failed: %s equal to NULL, got %v", assertionType, actualValue)
		}
	case "!=":
		if actualValue == nil {
			return fmt.Sprintf("Assertion failed: %s not equal to NULL, got NULL", assertionType)
		}
	default:
		return fmt.Sprintf("%s is not a valid assertion type", comparison)
	}
	return ""
}

// GetStringColAsString is a function that returns a text column as a string.
// This is necessary as the dolt_tests system table returns *val.TextStorage types under certain situations,
// so we use a special parser to get the correct string values
func GetStringColAsString(sqlCtx *sql.Context, tableValue interface{}) (*string, error) {
	if ts, ok := tableValue.(*val.TextStorage); ok {
		str, err := ts.Unwrap(sqlCtx)
		return &str, err
	} else if str, ok := tableValue.(string); ok {
		return &str, nil
	} else if tableValue == nil {
		return nil, nil
	} else {
		return nil, fmt.Errorf("unexpected type %T, was expecting string", tableValue)
	}
}


Review comment (suggestion):
```suggestion
		return fmt.Sprintf("%s is not a valid comparison for NULL values", comparison)
```

Code after:
		}
	case ">=":
		if realValue.LessThan(expectedValue) {
			return fmt.Sprintf("Assertion failed: %s greater than or equal to %v, got %v", assertionType, expectedValue, realValue)
		}
	default:
		return fmt.Sprintf("%s is not a valid comparison type", comparison)
	}
	return ""
}

// compareNullValue is a function used for comparing a null value.
// It takes in a comparison string from one of: "==", "!="
// It returns a string. The string is empty if the assertion passed, or has a message explaining the failure otherwise
func compareNullValue(comparison string, actualValue interface{}, assertionType string) string {
	switch comparison {
	case "==":
		if actualValue != nil {
			return fmt.Sprintf("Assertion failed: %s equal to NULL, got %v", assertionType, actualValue)
		}
	case "!=":
		if actualValue == nil {
			return fmt.Sprintf("Assertion failed: %s not equal to NULL, got NULL", assertionType)
		}
	default:
		return fmt.Sprintf("%s is not a valid comparison for NULL values", comparison)
	}
	return ""
}

// GetStringColAsString is a function that returns a text column as a string.
// This is necessary as the dolt_tests system table returns *val.TextStorage types under certain situations,
// so we use a special parser to get the correct string values
func GetStringColAsString(sqlCtx *sql.Context, tableValue interface{}) (*string, error) {
	if ts, ok := tableValue.(*val.TextStorage); ok {
		str, err := ts.Unwrap(sqlCtx)
		return &str, err
	} else if str, ok := tableValue.(string); ok {
		return &str, nil
	} else if tableValue == nil {
		return nil, nil
	} else {
		return nil, fmt.Errorf("unexpected type %T, was expecting string", tableValue)
	}
}