Skip to content

Commit

Permalink
test: junit postprocessor with path prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
devcatalin committed Oct 3, 2024
1 parent 0010ed7 commit ac23cbd
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions cmd/testworkflow-toolkit/artifacts/junit_post_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package artifacts
import (
"io"
"io/fs"
"path/filepath"
"testing"

"github.com/golang/mock/gomock"
Expand Down Expand Up @@ -71,6 +72,33 @@ func TestJUnitPostProcessor_Add(t *testing.T) {

}

func TestJUnitPostProcessor_Add_WithPathPrefix(t *testing.T) {
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()

mockFS := filesystem.NewMockFileSystem(mockCtrl)
mockClient := executor.NewMockExecutor(mockCtrl)

pathPrefix := "prefixed/junit/report/"
filePath := "junit.xml"
junitContent := []byte(testdata.BasicJUnit)

mockFS.EXPECT().OpenFileRO(gomock.Any()).Return(filesystem.NewMockFile("junit.xml", junitContent), nil)

pp := NewJUnitPostProcessor(mockFS, mockClient, "/test_root", pathPrefix)

expectedPayload := testworkflow.ExecutionsAddReportRequest{
Filepath: filepath.Join(pathPrefix, filePath),
Report: junitContent,
}

mockClient.EXPECT().Execute(gomock.Any(), testworkflow.CmdTestWorkflowExecutionAddReport, gomock.Eq(&expectedPayload)).Return(nil, nil)

err := pp.Add(filePath)

assert.NoError(t, err)
}

func TestIsXMLFile(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit ac23cbd

Please sign in to comment.