Skip to content

Commit

Permalink
unit/fix: use EFS reader to handle EFS data
Browse files Browse the repository at this point in the history
  • Loading branch information
mtulio committed Jul 12, 2024
1 parent bd3e542 commit bc8b7ea
Showing 1 changed file with 8 additions and 26 deletions.
34 changes: 8 additions & 26 deletions openshift-tests-plugin/cmd/exec/parser-test-suite_test.go
Original file line number Diff line number Diff line change
@@ -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{
Expand All @@ -62,9 +47,6 @@ func TestStartParseParserTestSuite(t *testing.T) {
SuiteList: suiteFile,
}
assert.NoError(t, StartParseParserTestSuite(&opts))

// Cleanup
testCleanUp(removeFiles)
}

func TestNewCmdParserTestSuite(t *testing.T) {
Expand Down

0 comments on commit bc8b7ea

Please sign in to comment.