added url fetching
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user