offline-twitter/scraper/link_expander_test.go

24 lines
472 B
Go
Raw Normal View History

2022-01-08 18:25:26 -05:00
package scraper_test
import (
"testing"
"net/http"
"net/http/httptest"
2022-03-13 17:09:43 -07:00
"github.com/stretchr/testify/assert"
. "offline_twitter/scraper"
2022-01-08 18:25:26 -05:00
)
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()
assert.Equal(t, redirecting_to, ExpandShortUrl(srvr.URL))
2022-01-08 18:25:26 -05:00
}