hmm/fetch_test.go

28 lines
437 B
Go
Raw Normal View History

2017-05-12 13:44:54 -07:00
package hmm
import (
"fmt"
"net/http"
"net/http/httptest"
"testing"
)
type dummy struct{}
func (d *dummy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
for i := 0; i < 10; i++ {
fmt.Fprintf(w, "here is a line: %d\n", i)
}
}
func TestFetch(t *testing.T) {
ts := httptest.NewServer(&dummy{})
i := 0
for range Lines(ts.URL) {
i++
}
if got, want := i, 10; got != want {
t.Fatalf("got %d, want %d", got, want)
}
}