From 51827a9ddfb4ae5e26b77f0952c71046a4dd61bf Mon Sep 17 00:00:00 2001 From: John Judd Date: Tue, 30 Jan 2024 16:09:32 -0600 Subject: [PATCH] address lint issues --- backend/testsuite/common.go | 2 +- backend/testsuite/io_integration_test.go | 40 ++++++++++++++---------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/backend/testsuite/common.go b/backend/testsuite/common.go index 06ee5587..9aec8b50 100644 --- a/backend/testsuite/common.go +++ b/backend/testsuite/common.go @@ -23,7 +23,7 @@ func CopyOsLocation(loc vfs.Location) vfs.Location { panic(err) } if !exists { - err := os.Mkdir(ret.Path(), 0755) + err := os.Mkdir(ret.Path(), 0750) if err != nil { panic(err) } diff --git a/backend/testsuite/io_integration_test.go b/backend/testsuite/io_integration_test.go index d54a79f6..2298dc6a 100644 --- a/backend/testsuite/io_integration_test.go +++ b/backend/testsuite/io_integration_test.go @@ -126,19 +126,25 @@ type ioTestSuite struct { localDir string } +/* +The following example shows how to setup the test suite to run against a local directory for unix file baseline + +// setup local tests +osTemp, err := os.MkdirTemp("", "vfs-io-test") +s.Require().NoError(err) + +// add baseline OS test +loc := osTemp + "/" +uris = append(uris, loc) + +// add vfs os test +loc = "file://" + loc +uris = append(uris, loc) + +*/ + func (s *ioTestSuite) SetupSuite() { uris := make([]string, 0) - // // setup local tests - // osTemp, err := os.MkdirTemp("", "vfs-io-test") - // s.Require().NoError(err) - // - // // add baseline OS test - // loc := osTemp + "/" - // uris = append(uris, loc) - // - // // add vfs os test - // loc = "file://" + loc - // uris = append(uris, loc) // add VFS_INTEGRATION_LOCATIONS tests locs := os.Getenv("VFS_INTEGRATION_LOCATIONS") @@ -382,6 +388,7 @@ func (s *ioTestSuite) testFileOperations(testPath string) { } } +//nolint:gocyclo func executeSequence(t *testing.T, file ReadWriteSeekCloseURINamer, sequence string) (string, error) { // split sequence by semicolon commands := strings.Split(sequence, ";") @@ -452,16 +459,17 @@ SEQ: } var f io.ReadCloser - if osfile, ok := file.(*OSWrapper); ok { + + switch assertedFile := file.(type) { + case *OSWrapper: var err error - f, err = os.Open(osfile.URI()) + f, err = os.Open(assertedFile.URI()) if err != nil { t.Fatalf("error opening file: %s", err.Error()) } - } else if vfsFile, ok := file.(vfs.File); ok { - // open new file + case vfs.File: var err error - f, err = vfsFile.Location().NewFile(file.Name()) + f, err = assertedFile.Location().NewFile(assertedFile.Name()) if err != nil { t.Fatalf("error opening file: %s", err.Error()) }