From bc8b7ea7b27c18b8711e5ca1312748ef55dc3536 Mon Sep 17 00:00:00 2001 From: Marco Braga Date: Fri, 12 Jul 2024 00:22:41 -0300 Subject: [PATCH] unit/fix: use EFS reader to handle EFS data --- .../cmd/exec/parser-test-suite_test.go | 34 +++++-------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/openshift-tests-plugin/cmd/exec/parser-test-suite_test.go b/openshift-tests-plugin/cmd/exec/parser-test-suite_test.go index 72daebf7..04b6a5af 100644 --- a/openshift-tests-plugin/cmd/exec/parser-test-suite_test.go +++ b/openshift-tests-plugin/cmd/exec/parser-test-suite_test.go @@ -1,41 +1,26 @@ package exec import ( - "fmt" - "os" "testing" tdata "github.com/redhat-openshift-ecosystem/provider-certification-plugins/openshift-tests-plugin/test" "github.com/stretchr/testify/assert" ) -func testCleanUp(files []string) { - for _, file := range files { - err := os.Remove(file) - if err != nil { - fmt.Printf("error removing file[%s]: %v", file, err) - } - } -} - func TestStartParseParserTestSuite(t *testing.T) { - removeFiles := []string{} - defer testCleanUp(removeFiles) + // removeFiles := []string{} + // defer testCleanUp(removeFiles) + td := tdata.NewTestReader() + defer td.CleanUp() - vfsSuite := "testdata/suites/suite10.list" - vfsSuiteData, err := tdata.TestData.ReadFile(vfsSuite) + // Extract the suite list from the VFS + suiteFile, err := td.OpenFile("testdata/suites/suite10.list") if err != nil { - t.Fatalf("error reading suite list data from VFS[%s]: %v", vfsSuite, err) - } - - suiteFile, err := tdata.WriteData(vfsSuiteData) - if err != nil { - t.Fatalf("error writing suite list from VFS[%s] to file: %v", suiteFile, err) + t.Fatalf("error opening suite file: %v", err) } outputFile := "/tmp/oplugin.test-parse-suite.output.txt" - removeFiles = append(removeFiles, outputFile) - removeFiles = append(removeFiles, suiteFile) + td.InsertTempFile(outputFile) // Test case 1: Valid suite list and output file opts := OptionsParserTestSuite{ @@ -62,9 +47,6 @@ func TestStartParseParserTestSuite(t *testing.T) { SuiteList: suiteFile, } assert.NoError(t, StartParseParserTestSuite(&opts)) - - // Cleanup - testCleanUp(removeFiles) } func TestNewCmdParserTestSuite(t *testing.T) {