Skip to content

Commit

Permalink
remove redundant tests in TestValidateResourceSchemaDefinition
Browse files Browse the repository at this point in the history
- only testing happy path
- moved other test cases to TestValidateResourceSchemaDefWithOptions
  • Loading branch information
lillchan committed Oct 29, 2019
1 parent 6749ff5 commit 11d03ee
Showing 1 changed file with 0 additions and 55 deletions.
55 changes: 0 additions & 55 deletions openapi/openapi_v2_spec_analyser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1251,61 +1251,6 @@ func TestValidateResourceSchemaDefinition(t *testing.T) {
So(err, ShouldBeNil)
})
})
Convey("When validateResourceSchemaDefinition method is called with a valid schema definition missing an ID property but a different property acts as unique identifier'", func() {
schema := &spec.Schema{
SchemaProps: spec.SchemaProps{
Properties: map[string]spec.Schema{
"name": {
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{
extTfID: true,
},
},
},
},
},
}
err := a.validateResourceSchemaDefinition(schema)
Convey("Then error returned should be nil", func() {
So(err, ShouldBeNil)
})
})
Convey("When validateResourceSchemaDefinition method is called with a valid schema definition with both a property that name 'id' and a different property with the 'x-terraform-id' extension'", func() {
schema := &spec.Schema{
SchemaProps: spec.SchemaProps{
Properties: map[string]spec.Schema{
"id": {},
"name": {
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{
extTfID: true,
},
},
},
},
},
}
err := a.validateResourceSchemaDefinition(schema)
Convey("Then error returned should be nil", func() {
So(err, ShouldBeNil)
})
})
Convey("When validateResourceSchemaDefinition method is called with a NON valid schema definition due to missing unique identifier'", func() {
schema := &spec.Schema{
SchemaProps: spec.SchemaProps{
Properties: map[string]spec.Schema{
"name": {},
},
},
}
err := a.validateResourceSchemaDefinition(schema)
Convey("Then error returned should NOT be nil", func() {
So(err, ShouldNotBeNil)
})
Convey("And the error message should be", func() {
So(err.Error(), ShouldContainSubstring, "resource schema is missing a property that uniquely identifies the resource, either a property named 'id' or a property with the extension 'x-terraform-id' set to true")
})
})
})
}

Expand Down

0 comments on commit 11d03ee

Please sign in to comment.