Skip to content

Commit

Permalink
fix: add unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Sukhin <vladislav@kubeshop.io>
  • Loading branch information
vsukhin committed Feb 5, 2025
1 parent a65074d commit ab613ce
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions pkg/cloud/data/webhook/webhook_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package webhook

import (
"context"
"encoding/json"
"testing"

gomock "github.com/golang/mock/gomock"

Check failure on line 8 in pkg/cloud/data/webhook/webhook_test.go

View workflow job for this annotation

GitHub Actions / Lint Go

File is not properly formatted (goimports)
"github.com/kubeshop/testkube/pkg/api/v1/testkube"
"github.com/kubeshop/testkube/pkg/cloud/data/executor"
)

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

mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()

mockExecutor := executor.NewMockExecutor(mockCtrl)
repo := &CloudRepository{mockExecutor}

expectedResponse := WebhookExecutionCollectResultResponse{}
expectedResponseBytes, _ := json.Marshal(expectedResponse)

mockExecutor.
EXPECT().
Execute(context.Background(), CmdWebhookExecutionCollectResult, WebhookExecutionCollectResultRequest{WebhookName: "webhook"}).
Return(expectedResponseBytes, nil)

err := repo.CollectExecutionResult(context.Background(), testkube.Event{}, "webhook", "", 0)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
}

0 comments on commit ab613ce

Please sign in to comment.