From b49e511b911b6e0d5c7037e6006b418d588b9e88 Mon Sep 17 00:00:00 2001 From: Bram Vandenbogaerde Date: Sun, 26 May 2024 15:13:47 +0200 Subject: [PATCH] fix(tests): minor fixes to check equality between fileinfos and stat previous version would 'sanity' check with permission 0777 only, we now check whether the permissions correspond with the file on the remote server. --- client.go | 4 ++-- tests/basic_test.go | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/client.go b/client.go index a4d9e1f..bde8638 100644 --- a/client.go +++ b/client.go @@ -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) } @@ -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() diff --git a/tests/basic_test.go b/tests/basic_test.go index 7e92a49..3eff3d8 100644 --- a/tests/basic_test.go +++ b/tests/basic_test.go @@ -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") @@ -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),