Skip to content

Commit

Permalink
fixed: unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
primalmotion committed Apr 24, 2017
1 parent a03545f commit a9204be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestError_NewErrors(t *testing.T) {

Convey("Then the Error should be correctly initialized", func() {
So(errs, ShouldResemble, Errors{e1, e2})
So(errs.Error(), ShouldResemble, "error 0: error 42 (containers): bad: something bad\nerror 1: error 43 (containers1): bad1: something bad1\n")
So(errs.Error(), ShouldResemble, "error 42 (containers): bad: something bad, error 43 (containers1): bad1: something bad1")
So(errs.Code(), ShouldEqual, 42)
})
})
Expand Down
18 changes: 9 additions & 9 deletions unmarshaljson_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestUnmarshalJSONWithInvalidJSON(t *testing.T) {
server := &Server{}
err := UnmarshalJSON([]byte(`{"parentType" : 123`), server)

So(err.Error(), ShouldResemble, "error 0: error 400 (elemental): Bad Request: Invalid JSON\n")
So(err.Error(), ShouldResemble, "error 400 (elemental): Bad Request: Invalid JSON")
})
}

Expand All @@ -81,7 +81,7 @@ func TestUnmarshalJSONWithInvalidKeyAndValueJSON(t *testing.T) {
err := UnmarshalJSON(json, server)

So(err, ShouldNotBeNil)
So(err.Error(), ShouldResemble, "error 0: error 422 (elemental): Validation Error: Data '12' of attribute 'number' should be a 'integer'\n")
So(err.Error(), ShouldResemble, "error 422 (elemental): Validation Error: Data '12' of attribute 'number' should be a 'integer'")
})

Convey("Given I call the method UnmarshalJSON with a invalid json because string instead of int", t, func() {
Expand All @@ -91,7 +91,7 @@ func TestUnmarshalJSONWithInvalidKeyAndValueJSON(t *testing.T) {
err := UnmarshalJSON(json, server)

So(err, ShouldNotBeNil)
So(err.Error(), ShouldResemble, "error 0: error 422 (elemental): Validation Error: Data '12' of attribute 'annotation' should be a 'map[string]string'\n")
So(err.Error(), ShouldResemble, "error 422 (elemental): Validation Error: Data '12' of attribute 'annotation' should be a 'map[string]string'")
})

Convey("Given I call the method UnmarshalJSON with a invalid json because []int instead of []string", t, func() {
Expand All @@ -101,7 +101,7 @@ func TestUnmarshalJSONWithInvalidKeyAndValueJSON(t *testing.T) {
err := UnmarshalJSON(json, server)

So(err, ShouldNotBeNil)
So(err.Error(), ShouldResemble, "error 0: error 422 (elemental): Validation Error: Data '[12]' of attribute 'associatedTags' should be a '[]string'\n")
So(err.Error(), ShouldResemble, "error 422 (elemental): Validation Error: Data '[12]' of attribute 'associatedTags' should be a '[]string'")
})

Convey("Given I call the method UnmarshalJSON with an invalid contant type", t, func() {
Expand All @@ -111,7 +111,7 @@ func TestUnmarshalJSONWithInvalidKeyAndValueJSON(t *testing.T) {
err := UnmarshalJSON(json, server)

So(err, ShouldNotBeNil)
So(err.Error(), ShouldResemble, "error 0: error 422 (elemental): Validation Error: Data '12' of attribute 'boom' should be a 'string'\n")
So(err.Error(), ShouldResemble, "error 422 (elemental): Validation Error: Data '12' of attribute 'boom' should be a 'string'")
})

Convey("Given I call the method UnmarshalJSON with an invalid key", t, func() {
Expand All @@ -121,7 +121,7 @@ func TestUnmarshalJSONWithInvalidKeyAndValueJSON(t *testing.T) {
err := UnmarshalJSON(json, server)

So(err, ShouldNotBeNil)
So(err.Error(), ShouldResemble, "error 0: error 422 (elemental): Validation Error: Data '12' of attribute 'updatedAt' should be a 'string in format YYYY-MM-DDTHH:MM:SSZ'\n")
So(err.Error(), ShouldResemble, "error 422 (elemental): Validation Error: Data '12' of attribute 'updatedAt' should be a 'string in format YYYY-MM-DDTHH:MM:SSZ'")
})

Convey("Given I call the method UnmarshalJSON with an empty string for a list of string", t, func() {
Expand All @@ -132,7 +132,7 @@ func TestUnmarshalJSONWithInvalidKeyAndValueJSON(t *testing.T) {
err := UnmarshalJSON(json, server)

So(err, ShouldNotBeNil)
So(err.Error(), ShouldResemble, "error 0: error 422 (elemental): Validation Error: Data '12' of attribute 'parentType' should be a 'string'\n")
So(err.Error(), ShouldResemble, "error 422 (elemental): Validation Error: Data '12' of attribute 'parentType' should be a 'string'")
})

Convey("Given I call the method UnmarshalJSON with an valid list of strings for a list of string", t, func() {
Expand All @@ -143,7 +143,7 @@ func TestUnmarshalJSONWithInvalidKeyAndValueJSON(t *testing.T) {
err := UnmarshalJSON(json, server)

So(err, ShouldNotBeNil)
So(err.Error(), ShouldResemble, "error 0: error 422 (elemental): Validation Error: Data '12' of attribute 'parentType' should be a 'string'\n")
So(err.Error(), ShouldResemble, "error 422 (elemental): Validation Error: Data '12' of attribute 'parentType' should be a 'string'")
})

Convey("Given I call the method UnmarshalJSON with an null value for a of string", t, func() {
Expand All @@ -154,6 +154,6 @@ func TestUnmarshalJSONWithInvalidKeyAndValueJSON(t *testing.T) {
err := UnmarshalJSON(json, server)

So(err, ShouldNotBeNil)
So(err.Error(), ShouldResemble, "error 0: error 422 (elemental): Validation Error: Data '12' of attribute 'parentType' should be a 'string'\n")
So(err.Error(), ShouldResemble, "error 422 (elemental): Validation Error: Data '12' of attribute 'parentType' should be a 'string'")
})
}

0 comments on commit a9204be

Please sign in to comment.