add tests for upload with fallback for root path

This commit is contained in:
zelig 2015-06-02 16:32:46 +01:00
parent 585b52c472
commit 5292414f11

View file

@ -81,7 +81,6 @@ func TestApiDirUpload(t *testing.T) {
content, err := ioutil.ReadFile(path.Join(testDir, "test0", "index.html")) content, err := ioutil.ReadFile(path.Join(testDir, "test0", "index.html"))
testGet(t, api, path.Join(bzzhash, "index.html"), content, "text/html", 0, 202) testGet(t, api, path.Join(bzzhash, "index.html"), content, "text/html", 0, 202)
testGet(t, api, bzzhash, content, "text/html", 0, 202)
content, err = ioutil.ReadFile(path.Join(testDir, "test0", "index.css")) content, err = ioutil.ReadFile(path.Join(testDir, "test0", "index.css"))
testGet(t, api, path.Join(bzzhash, "index.css"), content, "text/plain", 0, 132) testGet(t, api, path.Join(bzzhash, "index.css"), content, "text/plain", 0, 132)
@ -95,6 +94,22 @@ func TestApiDirUpload(t *testing.T) {
} }
} }
func TestApiDirUploadWithRootFile(t *testing.T) {
api, err := testApi()
if err != nil {
t.Errorf("unexpected error: %v", err)
return
}
bzzhash, err := api.Upload(path.Join(testDir, "test0"), "index.html")
if err != nil {
t.Errorf("unexpected error: %v", err)
return
}
content, err := ioutil.ReadFile(path.Join(testDir, "test0", "index.html"))
testGet(t, api, bzzhash, content, "text/html", 0, 202)
}
func TestApiFileUpload(t *testing.T) { func TestApiFileUpload(t *testing.T) {
api, err := testApi() api, err := testApi()
if err != nil { if err != nil {
@ -108,5 +123,5 @@ func TestApiFileUpload(t *testing.T) {
} }
content, err := ioutil.ReadFile(path.Join(testDir, "test0", "index.html")) content, err := ioutil.ReadFile(path.Join(testDir, "test0", "index.html"))
testGet(t, api, path.Join(bzzhash), content, "text/html", 0, 202) testGet(t, api, bzzhash, content, "text/html", 0, 202)
} }