Skip to content

Commit

Permalink
httpfs test Put
Browse files Browse the repository at this point in the history
  • Loading branch information
barnex committed Jan 8, 2015
1 parent 5eb78bd commit b41dd34
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions httpfs/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func Append(URL string, p []byte) error {
return AppendSize(URL, p, -1)
}

// Create file given by URL and put data from p there.
func Put(URL string, p []byte) error {
URL = addWorkDir(URL)
if isRemote(URL) {
Expand Down
22 changes: 22 additions & 0 deletions httpfs/httpfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,28 @@ func TestAppendRead(t *testing.T) {
}
}

func TestPutRead(t *testing.T) {
Remove("testdata")
defer Remove("testdata")

mustPass(t, Mkdir("testdata"))

data := []byte("hello httpfs\n")

// must pass if file does not yet exist
for i := 0; i < MANYFILES; i++ {
mustPass(t, Put("testdata/file", data))
}

b, errR := Read("testdata/file")
if errR != nil {
t.Error(errR)
}
if len(b) != len(data) {
t.Error(len(b), (MANYFILES+1)*len(data))
}
}

func mustPass(t *testing.T, err error) {
if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit b41dd34

Please sign in to comment.