package add import ( "encoding/json" mh "github.com/jbenet/go-multihash" "github.com/stretchr/testify/assert" config "github.com/travisperson/ipfs-api-test/config" files "github.com/travisperson/ipfs-api-test/files" "net/http" "strings" "testing" ) var uri string = config.U("/api/v0/add") func Get(t *testing.T) { assert := assert.New(t) resp, err := http.Get(uri) assert.NoError(err) assert.Equal(http.StatusMethodNotAllowed, resp.StatusCode) } func PostEmpty(t *testing.T) { assert := assert.New(t) resp, err := http.Post(uri, "text/plain", strings.NewReader("")) assert.NoError(err) assert.Equal(http.StatusBadRequest, resp.StatusCode)
package cat import ( "encoding/json" "github.com/stretchr/testify/assert" config "github.com/travisperson/ipfs-api-test/config" files "github.com/travisperson/ipfs-api-test/files" add "github.com/travisperson/ipfs-api-test/v0/add" "io/ioutil" "net/http" "testing" ) var uri string = config.U("/api/v0/cat") const fileName string = "file2.txt" const fileBody string = "Hello2" func before(t *testing.T) string { assert := assert.New(t) fs := []files.File{ {fileName, fileBody, "QmNULL"}, } request := add.AddFiles(t, fs) // Perform the request resp, err := http.DefaultClient.Do(request) assert.NoError(err)