Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "testing"
- "net/http/httptest"
- "net/http"
- "log"
- "sync"
- "generic"
- )
- type FakeTlinksMap struct{
- Links map[string]map[string]struct{}
- generic.TlinksMap
- sync.Mutex
- }
- func (*FakeTlinksMap) GetRandomLink(host string) string {
- log.Print("My link is running")
- return "http://example.com/path1"
- }
- func TestBasic(t *testing.T) {
- linksMap = &FakeTlinksMap{Links: make(map[string]map[string]struct{})}
- ts := httptest.NewServer(http.HandlerFunc(redirectHandler))
- defer ts.Close()
- // Set up the HTTP request
- req, err := http.NewRequest("GET", ts.URL, nil)
- //req.Header.Add("Host", "sd.ua")
- req.Host = "sd.ua"
- transport := http.Transport{}
- resp, err := transport.RoundTrip(req)
- if err != nil {
- t.Fatal(err)
- }
- log.Printf("Status code: %d", resp.StatusCode)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement