@cryptotaxi247 / kubo / commits / daf1b7280

api: fix failing test

This commit was moved from ipfs/go-ipfs-http-client@ea507216d821455c351440ba33775f564ea18ea8

Alex committed May 1, 2019 at 17:19 UTC daf1b72809a3d1af819d7ff44aabcc6bc6471fe8
1 file changed +4 -4
client/httpapi/api_test.go
+4 -4
@@ -8,6 +8,7 @@ import (
8 "net/http/httptest"
9 "os"
10 "strconv"
11 + "strings"
12 "sync"
13 "testing"
14 "time"
@@ -221,15 +222,14 @@ func Test_NewURLApiWithClient_With_Headers(t *testing.T) {
222 ts := httptest.NewServer(
223 http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
224 val := r.Header.Get(headerToTest)
224 - if val == expectedHeaderValue {
225 + if val != expectedHeaderValue {
226 w.WriteHeader(400)
227 return
228 }
228 - w.WriteHeader(200)
229 + http.ServeContent(w, r, "", time.Now(), strings.NewReader("test"))
230 }),
231 )
232 defer ts.Close()
232 - time.Sleep(time.Second * 2)
233 api, err := NewURLApiWithClient(ts.URL, &http.Client{
234 Transport: &http.Transport{
235 Proxy: http.ProxyFromEnvironment,
@@ -240,7 +240,7 @@ func Test_NewURLApiWithClient_With_Headers(t *testing.T) {
240 t.Fatal(err)
241 }
242 api.Headers.Set(headerToTest, expectedHeaderValue)
243 - if _, err := api.Pin().Ls(context.Background()); err != nil {
243 + if err := api.Pin().Rm(context.Background(), path.New("/ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv")); err != nil {
244 t.Fatal(err)
245 }
246 }