package playground import ( "context" "net/http" "net/http/httptest" "strings" "testing" ) func TestShare(t *testing.T) { var resp string contents := "test" server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp += "test-" _, _ = w.Write([]byte(resp)) })) shareURL = server.URL link, err := Share(context.Background(), contents) if err != nil { t.Log(err) t.FailNow() } if !strings.EqualFold(string(link), resp) { t.Logf("Expected `%s` but got `%s`\n", resp, link) t.FailNow() } link2, err := Share(context.Background(), contents) if err != nil { t.Log(err) t.FailNow() } if !strings.EqualFold(string(link2), "test-") { t.Logf("Expected `test-` but got `%s`\n", link2) t.FailNow() } }