Skip to content

Commit

Permalink
Add fake DavClient
Browse files Browse the repository at this point in the history
Signed-off-by: Maria Shaldibina <[email protected]>
  • Loading branch information
krishicks authored and mariash committed Oct 23, 2014
1 parent a26f631 commit f5a8a2d
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions davcli/client/fakes/fake_client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package fakes

import (
"io"
)

type FakeClient struct {
GetPath string
GetContents io.ReadCloser
GetErr error

PutPath string
PutContents string
PutContentLength int64
PutErr error
}

func NewFakeClient() *FakeClient {
return &FakeClient{}
}

func (c *FakeClient) Get(path string) (io.ReadCloser, error) {
c.GetPath = path

return c.GetContents, c.GetErr
}

func (c *FakeClient) Put(path string, content io.ReadCloser, contentLength int64) error {
c.PutPath = path
contentBytes := make([]byte, contentLength)
content.Read(contentBytes)
defer content.Close()
c.PutContents = string(contentBytes)
c.PutContentLength = contentLength

return c.PutErr
}

0 comments on commit f5a8a2d

Please sign in to comment.