Example #1
0
func TestHandler(t *testing.T) {
	f := filetest.NewHandler("../show/test_example.html")
	defer f.Close()
	s := httptest.NewServer(f)
	defer s.Close()

	rec := httptest.NewRecorder()
	req, _ := http.NewRequest("GET", strings.TrimPrefix(s.URL, "http:/")+"/programs/a", nil)
	req.RequestURI = req.URL.String()
	Handler(rec, req)

	b, _ := ioutil.ReadFile("test_example.rss")
	if bytes.Equal(rec.Body.Bytes(), b) {
		t.Error("expected output to match example")
	}
}
Example #2
0
func TestShowGet(t *testing.T) {
	f := filetest.NewHandler("test_example.html")
	defer f.Close()
	s := httptest.NewServer(f)
	defer s.Close()

	show, _ := Get(s.URL)
	if show.Name != "Solid Action" {
		t.Errorf("unexpected show name: %q", show.Name)
	}
	if show.Author != "Tony Lima" {
		t.Errorf("unexpected author: %q", show.Author)
	}
	if l := len(show.Episodes); l != 1 {
		t.Errorf("expected one episodes, got: %d", l)
	}
}