- use Stretchr assert package for assertions - use "dot imports" to remove "scraper.XYZ" from everything
25 lines
476 B
Go
25 lines
476 B
Go
package scraper_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"net/http"
|
|
"net/http/httptest"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
. "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()
|
|
|
|
assert.Equal(t, redirecting_to, ExpandShortUrl(srvr.URL))
|
|
}
|