-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
525 additions
and
601 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,9 +38,7 @@ func (ts *fileTestSuite) SetupTest() { | |
ts.ftpClientMock = &mocks.Client{} | ||
ts.fs = FileSystem{ftpclient: ts.ftpClientMock, options: Options{}} | ||
ts.testFile, err = ts.fs.NewFile("[email protected]:22", "/some/path/to/file.txt") | ||
if err != nil { | ||
ts.Fail("Shouldn't return error creating test ftp.File instance.") | ||
} | ||
ts.Require().NoError(err, "Shouldn't return error creating test ftp.File instance.") | ||
} | ||
|
||
var errClientGetter = errors.New("some dataconn getter error") | ||
|
@@ -76,7 +74,7 @@ func (ts *fileTestSuite) TestRead() { | |
var localFile = bytes.NewBuffer([]byte{}) | ||
b, copyErr := io.Copy(localFile, ftpfile) | ||
ts.NoError(copyErr, "no error expected") | ||
ts.EqualValues(len(contents), b, "byte count after copy") | ||
ts.Len(contents, int(b), "byte count after copy") | ||
ts.Equal(contents, localFile.String(), "Copying an ftp file to a buffer should fill buffer with localfile's contents") | ||
|
||
// test read error | ||
|
@@ -85,7 +83,7 @@ func (ts *fileTestSuite) TestRead() { | |
cnt, rErr := ftpfile.Read(make([]byte, 1)) | ||
ts.Error(rErr, "no error expected") | ||
ts.ErrorIs(rErr, myReadErr, "error is a read error") | ||
ts.Equal(0, cnt, "byte count is 0") | ||
ts.Zero(cnt, "byte count is 0") | ||
|
||
// get dataconn error | ||
dconnErr := errors.New("some getDataConn error") | ||
|
@@ -163,17 +161,17 @@ func (ts *fileTestSuite) TestWrite() { | |
|
||
// test write success | ||
count, err := file.Write([]byte(contents)) | ||
ts.Equal(len(contents), count, "Returned count of bytes written should match number of bytes passed to Write.") | ||
ts.Len(contents, count, "Returned count of bytes written should match number of bytes passed to Write.") | ||
ts.Equal(fakeDataConn.GetWriteContents(), contents, "expected contents written") | ||
ts.Nil(err, "Error should be nil when calling Write") | ||
ts.NoError(err, "Error should be nil when calling Write") | ||
|
||
// test write failure | ||
myWriteErr := errors.New("some write error") | ||
fakeDataConn.AssertWriteErr(myWriteErr) | ||
count, wErr := file.Write([]byte(contents)) | ||
ts.Error(wErr, "no error expected") | ||
ts.ErrorIs(wErr, myWriteErr, "error is a write error") | ||
ts.Equal(0, count, "byte count is 0") | ||
ts.Zero(count, "byte count is 0") | ||
|
||
// get client error | ||
dconnErr := errors.New("some getDataConn error") | ||
|
@@ -1113,7 +1111,7 @@ func (ts *fileTestSuite) TestSize() { | |
size, err = ts.testFile.Size() | ||
ts.Error(err, "expect error") | ||
ts.ErrorIs(err, myErr, "got correct error") | ||
ts.Equal(uint64(0), size, "Size should be 0 on error") | ||
ts.Zero(size, "Size should be 0 on error") | ||
|
||
ts.ftpClientMock.AssertExpectations(ts.T()) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.