Beispiel #1
0
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]))
		}
	}
}
Beispiel #2
0
func getPostList(w http.ResponseWriter, r *http.Request) {
	WriteJson(w, map[string][]string{"Posts": posts.GetPostList()})
}