diff --git a/schema/oneof_string_test.go b/schema/oneof_string_test.go index d01f8dd..9ecc875 100644 --- a/schema/oneof_string_test.go +++ b/schema/oneof_string_test.go @@ -247,26 +247,6 @@ func TestOneOfStringCompatibilityMapValidation(t *testing.T) { assert.Error(t, oneOfStringTestObjectASchema.ValidateCompatibility(combinedMapAndInvalidSchema)) } -var oneOfStringTestInlineObjectAProperties = map[string]*schema.PropertySchema{ - "s": schema.NewPropertySchema( - schema.NewOneOfStringSchema[any]( - map[string]schema.Object{ - "B": schema.NewRefSchema("B", nil), - "C": schema.NewRefSchema("C", nil), - }, - "choice", - true, - ), - nil, - true, - nil, - nil, - nil, - nil, - nil, - ), -} - type inlinedTestObjectA struct { DType string `json:"d_type"` OtherFieldA string `json:"other_field_a"` @@ -457,13 +437,12 @@ func TestOneOf_NonInlinedNonStructMapped(t *testing.T) { assert.Equals[any](t, reserializedData, serializedData) var input_mismatched_type any = struct{}{} - error_msg := fmt.Sprintf("Invalid type for one-of schema") err := oneofSchema.Validate(input_mismatched_type) assert.Error(t, err) - assert.Contains(t, err.Error(), error_msg) + assert.Contains(t, err.Error(), "Invalid type for one-of schema") var input_invalid_type any = true - error_msg = fmt.Sprintf("Invalid type for one-of type: %q. Expected map.", reflect.TypeOf(input_invalid_type).Kind()) + error_msg := fmt.Sprintf("Invalid type for one-of type: %q. Expected map.", reflect.TypeOf(input_invalid_type).Kind()) _, err = oneofSchema.Unserialize(input_invalid_type) assert.Error(t, err) assert.Contains(t, err.Error(), error_msg) diff --git a/schema/oneof_test.go b/schema/oneof_test.go index eaefc9c..c45f31c 100644 --- a/schema/oneof_test.go +++ b/schema/oneof_test.go @@ -24,20 +24,6 @@ type oneOfTestObjectA struct { S any `json:"s"` } -type oneOfTestInlineObjectB struct { - Message string `json:"message"` - Choice string `json:"choice"` -} - -func (o oneOfTestInlineObjectB) String() string { - return o.Message -} - -type oneOfTestInlineObjectC struct { - M string `json:"m"` - Choice string `json:"choice"` -} - func TestOneOfTypeID(t *testing.T) { assert.Equals( t, @@ -141,72 +127,6 @@ var oneOfTestCMappedSchema = schema.NewStructMappedObjectSchema[oneOfTestObjectC oneOfTestObjectCProperties, ) -var oneOfTestInlineObjectBProperties = map[string]*schema.PropertySchema{ - "message": schema.NewPropertySchema( - schema.NewStringSchema(nil, nil, nil), - nil, - true, - nil, - nil, - nil, - nil, - nil, - ), - "choice": schema.NewPropertySchema( - schema.NewStringSchema(nil, nil, nil), - nil, - true, - nil, - nil, - nil, - nil, - nil, - ), -} - -var oneOfTestInlineObjectCProperties = map[string]*schema.PropertySchema{ - "m": schema.NewPropertySchema( - schema.NewStringSchema(nil, nil, nil), - nil, - true, - nil, - nil, - nil, - nil, - nil, - ), - "choice": schema.NewPropertySchema( - schema.NewStringSchema(nil, nil, nil), - nil, - true, - nil, - nil, - nil, - nil, - nil, - ), -} - -var oneOfTestInlineBSchema = schema.NewObjectSchema( - "B", - oneOfTestInlineObjectBProperties, -) - -var oneOfTestInlineCSchema = schema.NewObjectSchema( - "C", - oneOfTestInlineObjectCProperties, -) - -var oneOfTestInlineBMappedSchema = schema.NewStructMappedObjectSchema[oneOfTestInlineObjectB]( - "B", - oneOfTestInlineObjectBProperties, -) - -var oneOfTestInlineCMappedSchema = schema.NewStructMappedObjectSchema[oneOfTestInlineObjectC]( - "C", - oneOfTestInlineObjectCProperties, -) - // Test_OneOf_ConstructorBypass tests the behavior of a OneOf object created // by the Scope Scope Schema through unserialization of data without using a // New* constructor function, like NewOneOfStringSchema or NewOneOfIntSchema,