Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mfleader committed Feb 20, 2024
1 parent 5464419 commit a82b000
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 103 deletions.
25 changes: 2 additions & 23 deletions schema/oneof_string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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)
Expand Down
80 changes: 0 additions & 80 deletions schema/oneof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit a82b000

Please sign in to comment.