Adding test for ls cmd
This commit is contained in:
@@ -111,6 +111,7 @@ func runListCmd(ctx *cli.Context) {
|
||||
doListCmd(mcClientManager{}, u, globalDebugFlag)
|
||||
}
|
||||
}
|
||||
|
||||
func doListCmd(manager clientManager, u string, debug bool) {
|
||||
clnt, err := manager.getNewClient(u, debug)
|
||||
if err != nil {
|
||||
|
||||
+32
@@ -141,3 +141,35 @@ func (s *CmdTestSuite) TestCopyRecursive(c *C) {
|
||||
cl2.AssertExpectations(c)
|
||||
cl3.AssertExpectations(c)
|
||||
}
|
||||
|
||||
func (s *CmdTestSuite) TestLsCmdWithBucket(c *C) {
|
||||
// c.Skip("Incomplete")
|
||||
sourceURL, err := parseURL("http://example.com/bucket1/", nil)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
manager := &MockclientManager{}
|
||||
cl1 := &clientMocks.Client{}
|
||||
|
||||
data1 := "hello1"
|
||||
binarySum1 := md5.Sum([]byte(data1))
|
||||
etag1 := base64.StdEncoding.EncodeToString(binarySum1[:])
|
||||
dataLen1 := int64(len(data1))
|
||||
|
||||
data2 := "hello world 2"
|
||||
binarySum2 := md5.Sum([]byte(data2))
|
||||
etag2 := base64.StdEncoding.EncodeToString(binarySum2[:])
|
||||
dataLen2 := int64(len(data2))
|
||||
|
||||
items := []*client.Item{
|
||||
{Key: "hello1", LastModified: time.Now(), ETag: etag1, Size: dataLen1},
|
||||
{Key: "hello2", LastModified: time.Now(), ETag: etag2, Size: dataLen2},
|
||||
}
|
||||
|
||||
manager.On("getNewClient", sourceURL, false).Return(cl1, nil).Once()
|
||||
cl1.On("ListObjects", "bucket1", "").Return(items, nil).Once()
|
||||
doListCmd(manager, sourceURL, false)
|
||||
// TODO work out how to test printing
|
||||
|
||||
manager.AssertExpectations(c)
|
||||
cl1.AssertExpectations(c)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user