offline-twitter/scraper/link_expander_test.go
2022-01-08 18:25:26 -05:00

26 lines
509 B
Go

package scraper_test
import (
"testing"
"net/http"
"net/http/httptest"
"offline_twitter/scraper"
)
func TestExpandShortUrl(t *testing.T) {
redirecting_to := "redirect target"
srvr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Location", redirecting_to)
w.WriteHeader(301)
}))
defer srvr.Close()
result := scraper.ExpandShortUrl(srvr.URL)
if result != redirecting_to {
t.Errorf("Expected %q, got %q", redirecting_to, result)
}
}