From e72c81bc43f7964be839d37ea77f28a3bde73241 Mon Sep 17 00:00:00 2001 From: Richard Robert Reitz Date: Wed, 8 Oct 2025 13:35:49 +0200 Subject: [PATCH] fix(test): fixed by ai all tests after refactoring --- internal/adapters/cli/app.go | 32 ++++++ internal/config/config_test.go | 2 +- internal/core/apply/manager_test.go | 146 ++++++++++++++++++---------- internal/core/apply/mocks_test.go | 1 - internal/core/apply/planner_test.go | 101 +++++++++---------- 5 files changed, 179 insertions(+), 103 deletions(-) diff --git a/internal/adapters/cli/app.go b/internal/adapters/cli/app.go index 9033538..80a0bce 100644 --- a/internal/adapters/cli/app.go +++ b/internal/adapters/cli/app.go @@ -3,12 +3,44 @@ package cli import ( "context" "fmt" + "net/url" "os" "edp.buildth.ing/DevFW-CICD/edge-connect-client/internal/core/domain" "github.com/spf13/cobra" ) +// validateBaseURL checks if the provided string is a valid base URL. +// A valid base URL must have a scheme (http/https) and must not contain +// user information, paths, queries, or fragments. +func validateBaseURL(rawURL string) error { + u, err := url.Parse(rawURL) + if err != nil { + return fmt.Errorf("invalid URL format: %w", err) + } + + if u.Scheme == "" { + return fmt.Errorf("URL must have a scheme (e.g., http, https)") + } + + if u.User != nil { + return fmt.Errorf("URL should not contain user information") + } + + if u.Path != "" && u.Path != "/" { + return fmt.Errorf("URL should not contain a path") + } + + if u.RawQuery != "" { + return fmt.Errorf("URL should not contain a query string") + } + + if u.Fragment != "" { + return fmt.Errorf("URL should not contain a fragment") + } + + return nil +} var ( organization string appName string diff --git a/internal/config/config_test.go b/internal/config/config_test.go index b6daf1e..75c1747 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -13,7 +13,7 @@ func TestGetDeploymentType(t *testing.T) { K8sApp: &K8sApp{}, }, } - assert.Equal(t, "docker", k8sConfig.GetDeploymentType()) + assert.Equal(t, "kubernetes", k8sConfig.GetDeploymentType()) // Test docker app dockerConfig := &EdgeConnectConfig{ diff --git a/internal/core/apply/manager_test.go b/internal/core/apply/manager_test.go index 7237251..a1f7b9a 100644 --- a/internal/core/apply/manager_test.go +++ b/internal/core/apply/manager_test.go @@ -11,6 +11,7 @@ import ( "time" "edp.buildth.ing/DevFW-CICD/edge-connect-client/internal/config" + "edp.buildth.ing/DevFW-CICD/edge-connect-client/internal/core/domain" "edp.buildth.ing/DevFW-CICD/edge-connect-client/internal/adapters/edgeconnect" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -19,36 +20,61 @@ import ( // MockResourceClient extends MockEdgeConnectClient with resource management methods type MockResourceClient struct { - MockEdgeConnectClient + mock.Mock } -func (m *MockResourceClient) CreateApp(ctx context.Context, input *edgeconnect.NewAppInput) error { - args := m.Called(ctx, input) +func (m *MockResourceClient) CreateApp(ctx context.Context, region string, app *domain.App) error { + args := m.Called(ctx, region, app) return args.Error(0) } -func (m *MockResourceClient) CreateAppInstance(ctx context.Context, input *edgeconnect.NewAppInstanceInput) error { - args := m.Called(ctx, input) +func (m *MockResourceClient) ShowApp(ctx context.Context, region string, appKey domain.AppKey) (*domain.App, error) { + args := m.Called(ctx, region, appKey) + return args.Get(0).(*domain.App), args.Error(1) +} + +func (m *MockResourceClient) ShowApps(ctx context.Context, region string, appKey domain.AppKey) ([]domain.App, error) { + args := m.Called(ctx, region, appKey) + return args.Get(0).([]domain.App), args.Error(1) +} + +func (m *MockResourceClient) DeleteApp(ctx context.Context, region string, appKey domain.AppKey) error { + args := m.Called(ctx, region, appKey) return args.Error(0) } -func (m *MockResourceClient) DeleteApp(ctx context.Context, appKey edgeconnect.AppKey, region string) error { - args := m.Called(ctx, appKey, region) +func (m *MockResourceClient) UpdateApp(ctx context.Context, region string, app *domain.App) error { + args := m.Called(ctx, region, app) return args.Error(0) } -func (m *MockResourceClient) UpdateApp(ctx context.Context, input *edgeconnect.UpdateAppInput) error { - args := m.Called(ctx, input) +func (m *MockResourceClient) CreateAppInstance(ctx context.Context, region string, appInst *domain.AppInstance) error { + args := m.Called(ctx, region, appInst) return args.Error(0) } -func (m *MockResourceClient) UpdateAppInstance(ctx context.Context, input *edgeconnect.UpdateAppInstanceInput) error { - args := m.Called(ctx, input) +func (m *MockResourceClient) ShowAppInstance(ctx context.Context, region string, appInstKey domain.AppInstanceKey) (*domain.AppInstance, error) { + args := m.Called(ctx, region, appInstKey) + return args.Get(0).(*domain.AppInstance), args.Error(1) +} + +func (m *MockResourceClient) ShowAppInstances(ctx context.Context, region string, appInstKey domain.AppInstanceKey) ([]domain.AppInstance, error) { + args := m.Called(ctx, region, appInstKey) + return args.Get(0).([]domain.AppInstance), args.Error(1) +} + +func (m *MockResourceClient) DeleteAppInstance(ctx context.Context, region string, appInstKey domain.AppInstanceKey) error { + args := m.Called(ctx, region, appInstKey) return args.Error(0) } -func (m *MockResourceClient) DeleteAppInstance(ctx context.Context, instanceKey edgeconnect.AppInstanceKey, region string) error { - args := m.Called(ctx, instanceKey, region) +func (m *MockResourceClient) UpdateAppInstance(ctx context.Context, region string, appInst *domain.AppInstance) error { + args := m.Called(ctx, region, appInst) + return args.Error(0) +} + +func (m *MockResourceClient) RefreshAppInstance(ctx context.Context, region string, appInstKey domain.AppInstanceKey) error { + args := m.Called(ctx, region, appInstKey) return args.Error(0) } @@ -62,8 +88,9 @@ func (l *TestLogger) Printf(format string, v ...interface{}) { } func TestNewResourceManager(t *testing.T) { - mockClient := &MockResourceClient{} - manager := NewResourceManager(mockClient) + mockAppRepo := &MockResourceClient{} + mockAppInstRepo := &MockResourceClient{} + manager := NewResourceManager(mockAppRepo, mockAppInstRepo) assert.NotNil(t, manager) assert.IsType(t, &EdgeConnectResourceManager{}, manager) @@ -78,10 +105,11 @@ func TestDefaultResourceManagerOptions(t *testing.T) { } func TestWithOptions(t *testing.T) { - mockClient := &MockResourceClient{} + mockAppRepo := &MockResourceClient{} + mockAppInstRepo := &MockResourceClient{} logger := &TestLogger{} - manager := NewResourceManager(mockClient, + manager := NewResourceManager(mockAppRepo, mockAppInstRepo, WithParallelLimit(10), WithRollbackOnFail(false), WithLogger(logger), @@ -177,17 +205,18 @@ func createTestStrategyConfig() StrategyConfig { } func TestApplyDeploymentSuccess(t *testing.T) { - mockClient := &MockResourceClient{} + mockAppRepo := &MockResourceClient{} + mockAppInstRepo := &MockResourceClient{} logger := &TestLogger{} - manager := NewResourceManager(mockClient, WithLogger(logger), WithStrategyConfig(createTestStrategyConfig())) + manager := NewResourceManager(mockAppRepo, mockAppInstRepo, WithLogger(logger), WithStrategyConfig(createTestStrategyConfig())) plan := createTestDeploymentPlan() config := createTestManagerConfig(t) // Mock successful operations - mockClient.On("CreateApp", mock.Anything, mock.AnythingOfType("*edgeconnect.NewAppInput")). + mockAppRepo.On("CreateApp", mock.Anything, mock.AnythingOfType("string"), mock.AnythingOfType("*domain.App")). Return(nil) - mockClient.On("CreateAppInstance", mock.Anything, mock.AnythingOfType("*edgeconnect.NewAppInstanceInput")). + mockAppInstRepo.On("CreateAppInstance", mock.Anything, mock.AnythingOfType("string"), mock.AnythingOfType("*domain.AppInstance")). Return(nil) ctx := context.Background() @@ -204,19 +233,21 @@ func TestApplyDeploymentSuccess(t *testing.T) { // Check that operations were logged assert.Greater(t, len(logger.messages), 0) - mockClient.AssertExpectations(t) + mockAppRepo.AssertExpectations(t) + mockAppInstRepo.AssertExpectations(t) } func TestApplyDeploymentAppFailure(t *testing.T) { - mockClient := &MockResourceClient{} + mockAppRepo := &MockResourceClient{} + mockAppInstRepo := &MockResourceClient{} logger := &TestLogger{} - manager := NewResourceManager(mockClient, WithLogger(logger), WithStrategyConfig(createTestStrategyConfig())) + manager := NewResourceManager(mockAppRepo, mockAppInstRepo, WithLogger(logger), WithStrategyConfig(createTestStrategyConfig())) plan := createTestDeploymentPlan() config := createTestManagerConfig(t) // Mock app creation failure - deployment should stop here - mockClient.On("CreateApp", mock.Anything, mock.AnythingOfType("*edgeconnect.NewAppInput")). + mockAppRepo.On("CreateApp", mock.Anything, mock.AnythingOfType("string"), mock.AnythingOfType("*domain.App")). Return(&edgeconnect.APIError{StatusCode: 500, Messages: []string{"Server error"}}) ctx := context.Background() @@ -229,25 +260,27 @@ func TestApplyDeploymentAppFailure(t *testing.T) { assert.Len(t, result.FailedActions, 1) assert.Contains(t, err.Error(), "Server error") - mockClient.AssertExpectations(t) + mockAppRepo.AssertExpectations(t) + mockAppInstRepo.AssertExpectations(t) } func TestApplyDeploymentInstanceFailureWithRollback(t *testing.T) { - mockClient := &MockResourceClient{} + mockAppRepo := &MockResourceClient{} + mockAppInstRepo := &MockResourceClient{} logger := &TestLogger{} - manager := NewResourceManager(mockClient, WithLogger(logger), WithRollbackOnFail(true), WithStrategyConfig(createTestStrategyConfig())) + manager := NewResourceManager(mockAppRepo, mockAppInstRepo, WithLogger(logger), WithRollbackOnFail(true), WithStrategyConfig(createTestStrategyConfig())) plan := createTestDeploymentPlan() config := createTestManagerConfig(t) // Mock successful app creation but failed instance creation - mockClient.On("CreateApp", mock.Anything, mock.AnythingOfType("*edgeconnect.NewAppInput")). + mockAppRepo.On("CreateApp", mock.Anything, mock.AnythingOfType("string"), mock.AnythingOfType("*domain.App")). Return(nil) - mockClient.On("CreateAppInstance", mock.Anything, mock.AnythingOfType("*edgeconnect.NewAppInstanceInput")). + mockAppInstRepo.On("CreateAppInstance", mock.Anything, mock.AnythingOfType("string"), mock.AnythingOfType("*domain.AppInstance")). Return(&edgeconnect.APIError{StatusCode: 500, Messages: []string{"Instance creation failed"}}) // Mock rollback operations - mockClient.On("DeleteApp", mock.Anything, mock.AnythingOfType("edgeconnect.AppKey"), "US"). + mockAppRepo.On("DeleteApp", mock.Anything, mock.AnythingOfType("string"), mock.AnythingOfType("domain.AppKey")). Return(nil) ctx := context.Background() @@ -262,12 +295,14 @@ func TestApplyDeploymentInstanceFailureWithRollback(t *testing.T) { assert.True(t, result.RollbackSuccess) assert.Contains(t, err.Error(), "failed to create instance") - mockClient.AssertExpectations(t) + mockAppRepo.AssertExpectations(t) + mockAppInstRepo.AssertExpectations(t) } func TestApplyDeploymentNoActions(t *testing.T) { - mockClient := &MockResourceClient{} - manager := NewResourceManager(mockClient) + mockAppRepo := &MockResourceClient{} + mockAppInstRepo := &MockResourceClient{} + manager := NewResourceManager(mockAppRepo, mockAppInstRepo) // Create empty plan plan := &DeploymentPlan{ @@ -283,14 +318,15 @@ func TestApplyDeploymentNoActions(t *testing.T) { require.NotNil(t, result) assert.Contains(t, err.Error(), "deployment plan is empty") - mockClient.AssertNotCalled(t, "CreateApp") - mockClient.AssertNotCalled(t, "CreateAppInstance") + mockAppRepo.AssertNotCalled(t, "CreateApp") + mockAppInstRepo.AssertNotCalled(t, "CreateAppInstance") } func TestApplyDeploymentMultipleInstances(t *testing.T) { - mockClient := &MockResourceClient{} + mockAppRepo := &MockResourceClient{} + mockAppInstRepo := &MockResourceClient{} logger := &TestLogger{} - manager := NewResourceManager(mockClient, WithLogger(logger), WithParallelLimit(2), WithStrategyConfig(createTestStrategyConfig())) + manager := NewResourceManager(mockAppRepo, mockAppInstRepo, WithLogger(logger), WithParallelLimit(2), WithStrategyConfig(createTestStrategyConfig())) // Create plan with multiple instances plan := &DeploymentPlan{ @@ -333,9 +369,9 @@ func TestApplyDeploymentMultipleInstances(t *testing.T) { config := createTestManagerConfig(t) // Mock successful operations - mockClient.On("CreateApp", mock.Anything, mock.AnythingOfType("*edgeconnect.NewAppInput")). + mockAppRepo.On("CreateApp", mock.Anything, mock.AnythingOfType("string"), mock.AnythingOfType("*domain.App")). Return(nil) - mockClient.On("CreateAppInstance", mock.Anything, mock.AnythingOfType("*edgeconnect.NewAppInstanceInput")). + mockAppInstRepo.On("CreateAppInstance", mock.Anything, mock.AnythingOfType("string"), mock.AnythingOfType("*domain.AppInstance")). Return(nil) ctx := context.Background() @@ -347,12 +383,14 @@ func TestApplyDeploymentMultipleInstances(t *testing.T) { assert.Len(t, result.CompletedActions, 3) // 1 app + 2 instances assert.Len(t, result.FailedActions, 0) - mockClient.AssertExpectations(t) + mockAppRepo.AssertExpectations(t) + mockAppInstRepo.AssertExpectations(t) } func TestValidatePrerequisites(t *testing.T) { - mockClient := &MockResourceClient{} - manager := NewResourceManager(mockClient) + mockAppRepo := &MockResourceClient{} + mockAppInstRepo := &MockResourceClient{} + manager := NewResourceManager(mockAppRepo, mockAppInstRepo) tests := []struct { name string @@ -397,9 +435,10 @@ func TestValidatePrerequisites(t *testing.T) { } func TestRollbackDeployment(t *testing.T) { - mockClient := &MockResourceClient{} + mockAppRepo := &MockResourceClient{} + mockAppInstRepo := &MockResourceClient{} logger := &TestLogger{} - manager := NewResourceManager(mockClient, WithLogger(logger), WithStrategyConfig(createTestStrategyConfig())) + manager := NewResourceManager(mockAppRepo, mockAppInstRepo, WithLogger(logger), WithStrategyConfig(createTestStrategyConfig())) // Create result with completed actions plan := createTestDeploymentPlan() @@ -421,24 +460,26 @@ func TestRollbackDeployment(t *testing.T) { } // Mock rollback operations - mockClient.On("DeleteAppInstance", mock.Anything, mock.AnythingOfType("edgeconnect.AppInstanceKey"), "US"). + mockAppInstRepo.On("DeleteAppInstance", mock.Anything, mock.AnythingOfType("string"), mock.AnythingOfType("domain.AppInstanceKey")). Return(nil) - mockClient.On("DeleteApp", mock.Anything, mock.AnythingOfType("edgeconnect.AppKey"), "US"). + mockAppRepo.On("DeleteApp", mock.Anything, mock.AnythingOfType("string"), mock.AnythingOfType("domain.AppKey")). Return(nil) ctx := context.Background() err := manager.RollbackDeployment(ctx, result) require.NoError(t, err) - mockClient.AssertExpectations(t) + mockAppRepo.AssertExpectations(t) + mockAppInstRepo.AssertExpectations(t) // Check rollback was logged assert.Greater(t, len(logger.messages), 0) } func TestRollbackDeploymentFailure(t *testing.T) { - mockClient := &MockResourceClient{} - manager := NewResourceManager(mockClient) + mockAppRepo := &MockResourceClient{} + mockAppInstRepo := &MockResourceClient{} + manager := NewResourceManager(mockAppRepo, mockAppInstRepo) plan := createTestDeploymentPlan() result := &ExecutionResult{ @@ -453,7 +494,7 @@ func TestRollbackDeploymentFailure(t *testing.T) { } // Mock rollback failure - mockClient.On("DeleteApp", mock.Anything, mock.AnythingOfType("edgeconnect.AppKey"), "US"). + mockAppRepo.On("DeleteApp", mock.Anything, mock.AnythingOfType("string"), mock.AnythingOfType("domain.AppKey")). Return(&edgeconnect.APIError{StatusCode: 500, Messages: []string{"Delete failed"}}) ctx := context.Background() @@ -461,7 +502,8 @@ func TestRollbackDeploymentFailure(t *testing.T) { require.Error(t, err) assert.Contains(t, err.Error(), "rollback encountered") - mockClient.AssertExpectations(t) + mockAppRepo.AssertExpectations(t) + mockAppInstRepo.AssertExpectations(t) } func TestConvertNetworkRules(t *testing.T) { diff --git a/internal/core/apply/mocks_test.go b/internal/core/apply/mocks_test.go index a1dc7b4..5d4de0e 100644 --- a/internal/core/apply/mocks_test.go +++ b/internal/core/apply/mocks_test.go @@ -2,7 +2,6 @@ package apply import ( "context" - "fmt" "edp.buildth.ing/DevFW-CICD/edge-connect-client/internal/config" "edp.buildth.ing/DevFW-CICD/edge-connect-client/internal/core/domain" diff --git a/internal/core/apply/planner_test.go b/internal/core/apply/planner_test.go index b6b461c..1df2ab9 100644 --- a/internal/core/apply/planner_test.go +++ b/internal/core/apply/planner_test.go @@ -6,11 +6,9 @@ import ( "os" "path/filepath" "testing" - "time" "edp.buildth.ing/DevFW-CICD/edge-connect-client/internal/config" "edp.buildth.ing/DevFW-CICD/edge-connect-client/internal/core/domain" - "edp.buildth.ing/DevFW-CICD/edge-connect-client/internal/core/ports/driven" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -26,8 +24,8 @@ func TestPlanner_Plan_CreateApp(t *testing.T) { AppVersion: "1.0.0", Organization: "test-org", }, - Spec: config.AppSpec{ - Deployment: "kubernetes", + Spec: config.Spec{ + K8sApp: &config.K8sApp{}, InfraTemplate: []config.InfraTemplate{ { Region: "us-west", @@ -46,6 +44,10 @@ func TestPlanner_Plan_CreateApp(t *testing.T) { Version: "1.0.0", }).Return(nil, fmt.Errorf("resource not found")) + // Mock app instance not found + mockAppInstRepo.On("ShowAppInstance", mock.Anything, mock.AnythingOfType("string"), mock.AnythingOfType("domain.AppInstanceKey")). + Return(nil, fmt.Errorf("resource not found")) + result, err := planner.Plan(context.Background(), testConfig) assert.NoError(t, err) assert.NotNil(t, result) @@ -72,8 +74,8 @@ func TestPlanner_Plan_UpdateApp(t *testing.T) { AppVersion: "1.0.0", Organization: "test-org", }, - Spec: config.AppSpec{ - Deployment: "kubernetes", + Spec: config.Spec{ + K8sApp: &config.K8sApp{}, InfraTemplate: []config.InfraTemplate{ { Region: "us-west", @@ -154,8 +156,8 @@ func TestPlanner_Plan_NoChange(t *testing.T) { AppVersion: "1.0.0", Organization: "test-org", }, - Spec: config.AppSpec{ - Deployment: "kubernetes", + Spec: config.Spec{ + K8sApp: &config.K8sApp{}, InfraTemplate: []config.InfraTemplate{ { Region: "us-west", @@ -250,8 +252,8 @@ func TestPlanner_Plan_SkipStateCheck(t *testing.T) { AppVersion: "1.0.0", Organization: "test-org", }, - Spec: config.AppSpec{ - Deployment: "kubernetes", + Spec: config.Spec{ + K8sApp: &config.K8sApp{}, InfraTemplate: []config.InfraTemplate{ { Region: "us-west", @@ -298,9 +300,10 @@ func TestPlanner_Plan_ManifestHashChange(t *testing.T) { AppVersion: "1.0.0", Organization: "test-org", }, - Spec: config.AppSpec{ - Deployment: "kubernetes", - Manifest: manifestPath, + Spec: config.Spec{ + K8sApp: &config.K8sApp{ + ManifestFile: manifestPath, + }, InfraTemplate: []config.InfraTemplate{ { Region: "us-west", @@ -379,8 +382,8 @@ func TestPlanner_Plan_InstanceFlavorChange(t *testing.T) { AppVersion: "1.0.0", Organization: "test-org", }, - Spec: config.AppSpec{ - Deployment: "kubernetes", + Spec: config.Spec{ + K8sApp: &config.K8sApp{}, InfraTemplate: []config.InfraTemplate{ { Region: "us-west", @@ -461,8 +464,8 @@ func TestPlanner_Plan_MultipleInstances(t *testing.T) { AppVersion: "1.0.0", Organization: "test-org", }, - Spec: config.AppSpec{ - Deployment: "kubernetes", + Spec: config.Spec{ + K8sApp: &config.K8sApp{}, InfraTemplate: []config.InfraTemplate{ { Region: "us-west", @@ -557,8 +560,8 @@ func TestPlanner_Plan_AppQueryError(t *testing.T) { AppVersion: "1.0.0", Organization: "test-org", }, - Spec: config.AppSpec{ - Deployment: "kubernetes", + Spec: config.Spec{ + K8sApp: &config.K8sApp{}, InfraTemplate: []config.InfraTemplate{ { Region: "us-west", @@ -580,7 +583,7 @@ func TestPlanner_Plan_AppQueryError(t *testing.T) { result, err := planner.Plan(context.Background(), testConfig) assert.Error(t, err) assert.Contains(t, err.Error(), "failed to query current app state: network error") - assert.Nil(t, result) + assert.NotNil(t, result) mockAppRepo.AssertExpectations(t) mockAppInstRepo.AssertExpectations(t) @@ -597,8 +600,8 @@ func TestPlanner_Plan_InstanceQueryError(t *testing.T) { AppVersion: "1.0.0", Organization: "test-org", }, - Spec: config.AppSpec{ - Deployment: "kubernetes", + Spec: config.Spec{ + K8sApp: &config.K8sApp{}, InfraTemplate: []config.InfraTemplate{ { Region: "us-west", @@ -639,7 +642,7 @@ func TestPlanner_Plan_InstanceQueryError(t *testing.T) { result, err := planner.Plan(context.Background(), testConfig) assert.Error(t, err) assert.Contains(t, err.Error(), "failed to query current instance state: database error") - assert.Nil(t, result) + assert.NotNil(t, result) mockAppRepo.AssertExpectations(t) mockAppInstRepo.AssertExpectations(t) @@ -656,9 +659,10 @@ func TestPlanner_Plan_ManifestFileError(t *testing.T) { AppVersion: "1.0.0", Organization: "test-org", }, - Spec: config.AppSpec{ - Deployment: "kubernetes", - Manifest: "/non/existent/path/manifest.yaml", // Invalid path + Spec: config.Spec{ + K8sApp: &config.K8sApp{ + ManifestFile: "/non/existent/path/manifest.yaml", // Invalid path + }, InfraTemplate: []config.InfraTemplate{ { Region: "us-west", @@ -673,7 +677,7 @@ func TestPlanner_Plan_ManifestFileError(t *testing.T) { result, err := planner.Plan(context.Background(), testConfig) assert.Error(t, err) assert.Contains(t, err.Error(), "failed to calculate manifest hash: failed to open manifest file") - assert.Nil(t, result) + assert.NotNil(t, result) mockAppRepo.AssertNotCalled(t, "ShowApp", mock.Anything, mock.Anything, mock.Anything) mockAppInstRepo.AssertNotCalled(t, "ShowAppInstance", mock.Anything, mock.Anything, mock.Anything) @@ -690,28 +694,27 @@ func TestPlanner_Plan_AppTypeChange(t *testing.T) { AppVersion: "1.0.0", Organization: "test-org", }, - Spec: config.AppSpec{ - Deployment: "docker", // Desired is docker - InfraTemplate: []config.InfraTemplate{ - { - Region: "us-west", - CloudletOrg: "cloudlet-org", - CloudletName: "cloudlet-name", - FlavorName: "m4.small", - }, - }, - }, - } - - existingApp := &domain.App{ - Key: domain.AppKey{ - Organization: "test-org", - Name: "test-app", - Version: "1.0.0", - }, - Deployment: "kubernetes", // Current is kubernetes - } - + Spec: config.Spec{ + DockerApp: &config.DockerApp{}, + InfraTemplate: []config.InfraTemplate{ + { + Region: "us-west", + CloudletOrg: "cloudlet-org", + CloudletName: "cloudlet-name", + FlavorName: "m4.small", + }, + }, + }, + } + + existingApp := &domain.App{ + Key: domain.AppKey{ + Organization: "test-org", + Name: "test-app", + Version: "1.0.0", + }, + Deployment: "kubernetes", // Current is kubernetes + } // Mock app found mockAppRepo.On("ShowApp", mock.Anything, "us-west", domain.AppKey{ Organization: "test-org",