Skip to content

Commit

Permalink
More test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek Dowling committed Dec 22, 2015
1 parent 58cf5ea commit a3d742d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
14 changes: 10 additions & 4 deletions document_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ func TestDocument(t *testing.T) {
})

Convey("->AddObject()", func() {
obj, err := NewObject("1", "user", nil)
So(err, ShouldBeNil)

err = doc.AddObject(obj)
So(err, ShouldBeNil)
So(len(doc.Data), ShouldEqual, 1)
})

Convey("->AddError()", func() {
Expand All @@ -61,15 +66,16 @@ func TestDocument(t *testing.T) {
Convey("->Build()", func() {

testObject := &Object{
ID: "1",
Type: "Test",
ID: "1",
Type: "Test",
Status: http.StatusAccepted,
}

Convey("should accept an object", func() {
doc := Build(testObject)

So(doc.Data, ShouldResemble, list)
So(doc.Status, ShouldEqual, http.StatusOK)
So(doc.Data, ShouldResemble, List{testObject})
So(doc.Status, ShouldEqual, http.StatusAccepted)
})

Convey("should accept a list", func() {
Expand Down
2 changes: 2 additions & 0 deletions error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package jsh

import (
"net/http"
"net/http/httptest"
"strconv"
"testing"

Expand All @@ -13,6 +14,7 @@ func TestError(t *testing.T) {
Convey("Error Tests", t, func() {

request := &http.Request{}
writer := httptest.NewRecorder()

testErrorObject := &Error{
Status: http.StatusBadRequest,
Expand Down
3 changes: 1 addition & 2 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ func (p *Parser) Document(payload io.ReadCloser) (*Document, *Error) {
if decodeErr != nil {
return nil, ISE(fmt.Sprintf("Error parsing JSON Document: %s", decodeErr.Error()))
}
log.Printf("document = %+v\n", document.Data)

if document.HasData() {
for _, object := range document.Data {
Expand All @@ -132,7 +131,7 @@ func (p *Parser) Document(payload io.ReadCloser) (*Document, *Error) {
func closeReader(reader io.ReadCloser) {
err := reader.Close()
if err != nil {
log.Println("Unabled to close request Body")
log.Println("Unable to close request Body")
}
}

Expand Down
3 changes: 0 additions & 3 deletions response.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package jsh
import (
"encoding/json"
"fmt"
"log"
"net/http"
"strconv"
)
Expand Down Expand Up @@ -33,11 +32,9 @@ func Send(w http.ResponseWriter, r *http.Request, payload Sendable) *Error {
return err
}

log.Printf("validationErr = %+v\n", validationErr)
payload = validationErr
}

log.Printf("payload = %+v\n", payload)
return SendDocument(w, r, Build(payload))
}

Expand Down

0 comments on commit a3d742d

Please sign in to comment.