Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Fix testutils.TearDownAndVerify #none (#424)
Browse files Browse the repository at this point in the history
* Stopped swallowing errors in testutils.TearDownAndVerify

Signed-off-by: Kamal Eybov <[email protected]>

* Fixed tests.

Signed-off-by: Kamal Eybov <[email protected]>

---------

Signed-off-by: Kamal Eybov <[email protected]>
  • Loading branch information
kamaleybov authored Oct 5, 2023
1 parent be75a9e commit 5fea354
Show file tree
Hide file tree
Showing 24 changed files with 170 additions and 137 deletions.
4 changes: 2 additions & 2 deletions cmd/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import (
"sort"
"testing"

"github.com/flyteorg/flytectl/cmd/testutils"
"github.com/stretchr/testify/assert"

"github.com/flyteorg/flytectl/cmd/testutils"
)

const testDataFolder = "../testdata/"

var setup = testutils.Setup
var tearDownAndVerify = testutils.TearDownAndVerify

func TestCreateCommand(t *testing.T) {
createCommand := RemoteCreateCommand()
Expand Down
13 changes: 7 additions & 6 deletions cmd/create/execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"fmt"
"testing"

"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/admin"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/core"
"github.com/golang/protobuf/proto"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/suite"
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/admin"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/core"

"github.com/flyteorg/flytectl/cmd/config"
cmdCore "github.com/flyteorg/flytectl/cmd/core"
"github.com/flyteorg/flytectl/cmd/testutils"
Expand Down Expand Up @@ -202,7 +203,7 @@ func (s *createSuite) Test_CreateTaskExecution() {
err := createExecutionCommand(s.Ctx, nil, s.CmdCtx)

s.NoError(err)
tearDownAndVerify(s.T(), s.Writer, `execution identifier project:"flytesnacks" domain:"development" name:"ff513c0e44b5b4a35aa5" `)
s.TearDownAndVerify(s.T(), `execution identifier project:"flytesnacks" domain:"development" name:"ff513c0e44b5b4a35aa5" `)
}

func (s *createSuite) Test_CreateTaskExecution_GetTaskError() {
Expand Down Expand Up @@ -243,7 +244,7 @@ func (s *createSuite) Test_CreateLaunchPlanExecution() {
err := createExecutionCommand(s.Ctx, nil, s.CmdCtx)

s.NoError(err)
tearDownAndVerify(s.T(), s.Writer, `execution identifier project:"flytesnacks" domain:"development" name:"f652ea3596e7f4d80a0e" `)
s.TearDownAndVerify(s.T(), `execution identifier project:"flytesnacks" domain:"development" name:"f652ea3596e7f4d80a0e" `)
}

func (s *createSuite) Test_CreateLaunchPlan_GetLaunchPlanError() {
Expand Down Expand Up @@ -277,7 +278,7 @@ func (s *createSuite) Test_CreateRelaunchExecution() {
err := createExecutionCommand(s.Ctx, nil, s.CmdCtx)

s.NoError(err)
tearDownAndVerify(s.T(), s.Writer, `execution identifier project:"flytesnacks" domain:"development" name:"f652ea3596e7f4d80a0e"`)
s.TearDownAndVerify(s.T(), `execution identifier project:"flytesnacks" domain:"development" name:"f652ea3596e7f4d80a0e" `)
}

func (s *createSuite) Test_CreateRecoverExecution() {
Expand All @@ -302,7 +303,7 @@ func (s *createSuite) Test_CreateRecoverExecution() {
err := createExecutionCommand(s.Ctx, nil, s.CmdCtx)

s.NoError(err)
tearDownAndVerify(s.T(), s.Writer, `execution identifier project:"flytesnacks" domain:"development" name:"f652ea3596e7f4d80a0e"`)
s.TearDownAndVerify(s.T(), `execution identifier project:"flytesnacks" domain:"development" name:"f652ea3596e7f4d80a0e"`)
}

func (s *createSuite) TestCreateExecutionFuncInvalid() {
Expand Down
6 changes: 3 additions & 3 deletions cmd/create/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func createProjectSetup() {
func TestCreateProjectFunc(t *testing.T) {
s := setup()
createProjectSetup()
defer tearDownAndVerify(t, s.Writer, "project created successfully.")
defer s.TearDownAndVerify(t, "project created successfully.")
project.DefaultProjectConfig.ID = projectValue
project.DefaultProjectConfig.Name = projectValue
project.DefaultProjectConfig.Labels = map[string]string{}
Expand All @@ -56,7 +56,7 @@ func TestCreateProjectFunc(t *testing.T) {
func TestEmptyProjectID(t *testing.T) {
s := setup()
createProjectSetup()
defer tearDownAndVerify(t, s.Writer, "")
defer s.TearDownAndVerify(t, "")
project.DefaultProjectConfig = &project.ConfigProject{}
s.MockAdminClient.OnRegisterProjectMatch(s.Ctx, projectRegisterRequest).Return(nil, nil)
err := createProjectsCommand(s.Ctx, []string{}, s.CmdCtx)
Expand All @@ -67,7 +67,7 @@ func TestEmptyProjectID(t *testing.T) {
func TestEmptyProjectName(t *testing.T) {
s := setup()
createProjectSetup()
defer tearDownAndVerify(t, s.Writer, "")
defer s.TearDownAndVerify(t, "")
project.DefaultProjectConfig.ID = projectValue
project.DefaultProjectConfig.Labels = map[string]string{}
project.DefaultProjectConfig.Description = ""
Expand Down
4 changes: 2 additions & 2 deletions cmd/delete/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"sort"
"testing"

"github.com/flyteorg/flytectl/cmd/testutils"
"github.com/stretchr/testify/assert"

"github.com/flyteorg/flytectl/cmd/testutils"
)

const (
Expand All @@ -14,7 +15,6 @@ const (
)

var setup = testutils.Setup
var tearDownAndVerify = testutils.TearDownAndVerify

func TestDeleteCommand(t *testing.T) {
deleteCommand := RemoteDeleteCommand()
Expand Down
6 changes: 3 additions & 3 deletions cmd/delete/execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestTerminateExecutionFunc(t *testing.T) {
assert.Nil(t, err)
s.MockAdminClient.AssertCalled(t, "TerminateExecution", s.Ctx, terminateExecRequests[0])
s.MockAdminClient.AssertCalled(t, "TerminateExecution", s.Ctx, terminateExecRequests[1])
tearDownAndVerify(t, s.Writer, "")
s.TearDownAndVerify(t, "")
}

func TestTerminateExecutionFuncWithError(t *testing.T) {
Expand All @@ -55,7 +55,7 @@ func TestTerminateExecutionFuncWithError(t *testing.T) {
assert.Equal(t, errors.New("failed to terminate"), err)
s.MockAdminClient.AssertCalled(t, "TerminateExecution", s.Ctx, terminateExecRequests[0])
s.MockAdminClient.AssertNotCalled(t, "TerminateExecution", s.Ctx, terminateExecRequests[1])
tearDownAndVerify(t, s.Writer, "")
s.TearDownAndVerify(t, "")
}

func TestTerminateExecutionFuncWithPartialSuccess(t *testing.T) {
Expand All @@ -68,5 +68,5 @@ func TestTerminateExecutionFuncWithPartialSuccess(t *testing.T) {
assert.Equal(t, errors.New("failed to terminate"), err)
s.MockAdminClient.AssertCalled(t, "TerminateExecution", s.Ctx, terminateExecRequests[0])
s.MockAdminClient.AssertCalled(t, "TerminateExecution", s.Ctx, terminateExecRequests[1])
tearDownAndVerify(t, s.Writer, "")
s.TearDownAndVerify(t, "")
}
4 changes: 2 additions & 2 deletions cmd/get/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (
"sort"
"testing"

"github.com/flyteorg/flytectl/cmd/testutils"
"github.com/stretchr/testify/assert"

"github.com/flyteorg/flytectl/cmd/testutils"
)

const projectValue = "dummyProject"
Expand All @@ -20,7 +21,6 @@ const workflowVersionValue = "wf_version"
const testDataFolder = "../testdata/"

var setup = testutils.Setup
var tearDownAndVerify = testutils.TearDownAndVerify

const (
testDataTempFile = "temp-output-file"
Expand Down
Loading

0 comments on commit 5fea354

Please sign in to comment.