Skip to content

Commit

Permalink
fix(tests): minor fixes to check equality between fileinfos and stat
Browse files Browse the repository at this point in the history
previous version would 'sanity' check with permission 0777 only,
we now check whether the permissions correspond with the file on the
remote server.
  • Loading branch information
bramvdbogaerde committed May 26, 2024
1 parent 887a016 commit b49e511
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func (a *Client) CopyPassThru(

// CopyFromRemote copies a file from the remote to the local file given by the `file`
// parameter. Use `CopyFromRemotePassThru` if a more generic writer
// is desired instead of writing directly to a file on the file system.?
// is desired instead of writing directly to a file on the file system.
func (a *Client) CopyFromRemote(ctx context.Context, file *os.File, remotePath string) error {
return a.CopyFromRemotePassThru(ctx, file, remotePath, nil)
}
Expand Down Expand Up @@ -353,7 +353,7 @@ func (a *Client) copyFromRemote(
var err error

defer func() {
// NOTE: this might send an already sent error another time, but since we only receive opne, this is fine. On the "happy-path" of this function, the error will be `nil` therefore completing the "err<-errCh" at the bottom of the function.
// NOTE: this might send an already sent error another time, but since we only receive one, this is fine. On the "happy-path" of this function, the error will be `nil` therefore completing the "err<-errCh" at the bottom of the function.
errCh <- err
// We must unblock the go routine first as we block on reading the channel later
wg.Done()
Expand Down
8 changes: 3 additions & 5 deletions tests/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,9 @@ func TestDownloadFile(t *testing.T) {

func TestDownloadFileInfo(t *testing.T) {
client := establishConnection(t)
defer client.Close()
f, _ := os.Open("./data/input.txt")
defer f.Close()
defer client.Close()

// Create a local file to write to.
// Create a local file to write the remote file to.
f, err := os.OpenFile("./tmp/output.txt", os.O_RDWR|os.O_CREATE, 0777)
if err != nil {
t.Errorf("Couldn't open the output file")
Expand Down Expand Up @@ -279,7 +277,7 @@ func TestDownloadFileInfo(t *testing.T) {
t.Errorf("File size does not match")
}

if fs.FileMode(fileInfos.Permissions) == fs.FileMode(0777) {
if fs.FileMode(fileInfos.Permissions) != fileStat.Mode() {
t.Errorf(
"File permissions don't match %s vs %s",
fs.FileMode(fileInfos.Permissions),
Expand Down

0 comments on commit b49e511

Please sign in to comment.