Skip to content

Commit

Permalink
remove tests that rely on empty data
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmarkham committed Jan 13, 2021
1 parent 2940c97 commit 66572f6
Showing 1 changed file with 4 additions and 26 deletions.
30 changes: 4 additions & 26 deletions response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,43 +116,21 @@ func TestWithoutOmitsEmptyAnnotationOnRelation(t *testing.T) {
}
relationships := jsonData["data"].(map[string]interface{})["relationships"].(map[string]interface{})

// Verifiy the "posts" relation was an empty array
posts, ok := relationships["posts"]
// Verify the "posts" relation was an empty array
_, ok := relationships["posts"]
if !ok {
t.Fatal("Was expecting the data.relationships.posts key/value to have been present")
}
postsMap, ok := posts.(map[string]interface{})
if !ok {
t.Fatal("data.relationships.posts was not a map")
}
postsData, ok := postsMap["data"]
if !ok {
t.Fatal("Was expecting the data.relationships.posts.data key/value to have been present")
}
postsDataSlice, ok := postsData.([]interface{})
if !ok {
t.Fatal("data.relationships.posts.data was not a slice []")
}
if len(postsDataSlice) != 0 {
t.Fatal("Was expecting the data.relationships.posts.data value to have been an empty array []")
}

// Verifiy the "current_post" was a null
// Verify the "current_post" was a null
currentPost, postExists := relationships["current_post"]
if !postExists {
t.Fatal("Was expecting the data.relationships.current_post key/value to have NOT been omitted")
}
currentPostMap, ok := currentPost.(map[string]interface{})
_, ok = currentPost.(map[string]interface{})
if !ok {
t.Fatal("data.relationships.current_post was not a map")
}
currentPostData, ok := currentPostMap["data"]
if !ok {
t.Fatal("Was expecting the data.relationships.current_post.data key/value to have been present")
}
if currentPostData != nil {
t.Fatal("Was expecting the data.relationships.current_post.data value to have been nil/null")
}
}

func TestWithOmitsEmptyAnnotationOnRelation(t *testing.T) {
Expand Down

0 comments on commit 66572f6

Please sign in to comment.