func TestGetPostList(t *testing.T) { postList := posts.GetPostList() expectedPostList := []string{"Bacon Ipsum2", "Bacon Ipsum"} if len(postList) != 2 { t.Error("Expected post list to be length 2") } for i, _ := range postList { if postList[i] != expectedPostList[i] { t.Error(fmt.Sprintf("Expected postList[%d] as %s", i, expectedPostList[i])) } } }
func getPostList(w http.ResponseWriter, r *http.Request) { WriteJson(w, map[string][]string{"Posts": posts.GetPostList()}) }