@@ -7,14 +7,12 @@ import (
77 "context"
88 "errors"
99 "fmt"
10- "os"
1110 "testing"
1211 "time"
1312
1413 appinstallstore "github.com/replicatedhq/embedded-cluster/api/internal/store/app/install"
1514 "github.com/replicatedhq/embedded-cluster/api/pkg/logger"
1615 "github.com/replicatedhq/embedded-cluster/api/types"
17- "github.com/replicatedhq/embedded-cluster/cmd/installer/kotscli"
1816 "github.com/replicatedhq/embedded-cluster/pkg/helm"
1917 "github.com/replicatedhq/embedded-cluster/pkg/release"
2018 kotsv1beta1 "github.com/replicatedhq/kotskinds/apis/kots/v1beta1"
@@ -130,97 +128,23 @@ func TestAppInstallManager_Install(t *testing.T) {
130128 databaseCall ,
131129 )
132130
133- configValues := kotsv1beta1.ConfigValues {
134- Spec : kotsv1beta1.ConfigValuesSpec {
135- Values : map [string ]kotsv1beta1.ConfigValue {
136- "key1" : {
137- Value : "value1" ,
138- },
139- "key2" : {
140- Value : "value2" ,
141- },
142- },
143- },
144- }
145-
146- // Create mock installer with detailed verification
147- mockKotsCLI := & kotscli.MockKotsCLI {}
148- mockKotsCLI .On ("Install" , mock .MatchedBy (func (opts kotscli.InstallOptions ) bool {
149- // Verify basic install options
150- if opts .AppSlug != "test-app" {
151- t .Logf ("AppSlug mismatch: expected 'test-app', got '%s'" , opts .AppSlug )
152- return false
153- }
154- if opts .License == nil {
155- t .Logf ("License is nil" )
156- return false
157- }
158- if opts .Namespace != "test-app" {
159- t .Logf ("Namespace mismatch: expected 'test-app', got '%s'" , opts .Namespace )
160- return false
161- }
162- if opts .ClusterID != "test-cluster" {
163- t .Logf ("ClusterID mismatch: expected 'test-cluster', got '%s'" , opts .ClusterID )
164- return false
165- }
166- if opts .AirgapBundle != "test-airgap.tar.gz" {
167- t .Logf ("AirgapBundle mismatch: expected 'test-airgap.tar.gz', got '%s'" , opts .AirgapBundle )
168- return false
169- }
170- if opts .ReplicatedAppEndpoint == "" {
171- t .Logf ("ReplicatedAppEndpoint is empty" )
172- return false
173- }
174- if opts .ConfigValuesFile == "" {
175- t .Logf ("ConfigValuesFile is empty" )
176- return false
177- }
178- if ! opts .DisableImagePush {
179- t .Logf ("DisableImagePush is false" )
180- return false
181- }
182-
183- // Verify config values file content
184- b , err := os .ReadFile (opts .ConfigValuesFile )
185- if err != nil {
186- t .Logf ("Failed to read config values file: %v" , err )
187- return false
188- }
189- var cv kotsv1beta1.ConfigValues
190- if err := kyaml .Unmarshal (b , & cv ); err != nil {
191- t .Logf ("Failed to unmarshal config values: %v" , err )
192- return false
193- }
194- if cv .Spec .Values ["key1" ].Value != "value1" {
195- t .Logf ("Config value key1 mismatch: expected 'value1', got '%s'" , cv .Spec .Values ["key1" ].Value )
196- return false
197- }
198- if cv .Spec .Values ["key2" ].Value != "value2" {
199- t .Logf ("Config value key2 mismatch: expected 'value2', got '%s'" , cv .Spec .Values ["key2" ].Value )
200- return false
201- }
202- return true
203- })).Return (nil )
204-
205131 // Create manager
206132 manager , err := NewAppInstallManager (
207133 WithClusterID ("test-cluster" ),
208134 WithAirgapBundle ("test-airgap.tar.gz" ),
209135 WithReleaseData (releaseData ),
210136 WithLicense (licenseBytes ),
211137 WithHelmClient (mockHelmClient ),
212- WithKotsCLI (mockKotsCLI ),
213138 WithLogger (logger .NewDiscardLogger ()),
214139 WithKubeClient (fakeKcli ),
215140 )
216141 require .NoError (t , err )
217142
218143 // Run installation with InstallableHelmCharts
219- err = manager .Install (context .Background (), installableCharts , configValues , nil , "" )
144+ err = manager .Install (context .Background (), installableCharts , nil , "" )
220145 require .NoError (t , err )
221146
222147 mockHelmClient .AssertExpectations (t )
223- mockKotsCLI .AssertExpectations (t )
224148 })
225149
226150 t .Run ("Install updates status correctly" , func (t * testing.T ) {
@@ -234,10 +158,6 @@ func TestAppInstallManager_Install(t *testing.T) {
234158 return opts .ChartPath != "" && opts .ReleaseName == "prometheus" && opts .Namespace == "monitoring"
235159 })).Return ("Release \" prometheus\" has been installed." , nil )
236160
237- // Create mock KOTS CLI
238- mockKotsCLI := & kotscli.MockKotsCLI {}
239- mockKotsCLI .On ("Install" , mock .Anything ).Return (nil )
240-
241161 // Create manager with initialized store
242162 store := appinstallstore .NewMemoryStore (appinstallstore .WithAppInstall (types.AppInstall {
243163 Status : types.Status {State : types .StatePending },
@@ -247,7 +167,6 @@ func TestAppInstallManager_Install(t *testing.T) {
247167 WithReleaseData (releaseData ),
248168 WithLicense (licenseBytes ),
249169 WithHelmClient (mockHelmClient ),
250- WithKotsCLI (mockKotsCLI ),
251170 WithLogger (logger .NewDiscardLogger ()),
252171 WithAppInstallStore (store ),
253172 WithKubeClient (fakeKcli ),
@@ -260,7 +179,7 @@ func TestAppInstallManager_Install(t *testing.T) {
260179 assert .Equal (t , types .StatePending , appInstall .Status .State )
261180
262181 // Run installation
263- err = manager .Install (t .Context (), installableCharts , kotsv1beta1. ConfigValues {}, nil , "" )
182+ err = manager .Install (t .Context (), installableCharts , nil , "" )
264183 require .NoError (t , err )
265184
266185 // Verify components status
@@ -269,7 +188,6 @@ func TestAppInstallManager_Install(t *testing.T) {
269188 assert .NotEmpty (t , appInstall .Components )
270189
271190 mockHelmClient .AssertExpectations (t )
272- mockKotsCLI .AssertExpectations (t )
273191 })
274192
275193 t .Run ("Install handles errors correctly" , func (t * testing.T ) {
@@ -299,7 +217,7 @@ func TestAppInstallManager_Install(t *testing.T) {
299217 require .NoError (t , err )
300218
301219 // Run installation (should fail)
302- err = manager .Install (t .Context (), installableCharts , kotsv1beta1. ConfigValues {}, nil , "" )
220+ err = manager .Install (t .Context (), installableCharts , nil , "" )
303221 assert .Error (t , err )
304222
305223 mockHelmClient .AssertExpectations (t )
@@ -445,10 +363,6 @@ func TestComponentStatusTracking(t *testing.T) {
445363 return opts .ReleaseName == "nginx" && opts .Namespace == "web"
446364 })).Return ("Release \" nginx\" has been installed." , nil ).Once ()
447365
448- // Create mock KOTS CLI
449- mockKotsCLI := & kotscli.MockKotsCLI {}
450- mockKotsCLI .On ("Install" , mock .Anything ).Return (nil )
451-
452366 // Create manager with in-memory store
453367 appInstallStore := appinstallstore .NewMemoryStore (appinstallstore .WithAppInstall (types.AppInstall {
454368 Status : types.Status {State : types .StatePending },
@@ -459,13 +373,12 @@ func TestComponentStatusTracking(t *testing.T) {
459373 WithLicense (licenseBytes ),
460374 WithClusterID ("test-cluster" ),
461375 WithHelmClient (mockHelmClient ),
462- WithKotsCLI (mockKotsCLI ),
463376 WithKubeClient (fakeKcli ),
464377 )
465378 require .NoError (t , err )
466379
467380 // Install the charts
468- err = manager .Install (t .Context (), installableCharts , kotsv1beta1. ConfigValues {}, nil , "" )
381+ err = manager .Install (t .Context (), installableCharts , nil , "" )
469382 require .NoError (t , err )
470383
471384 // Verify that components were registered and have correct status
@@ -483,7 +396,6 @@ func TestComponentStatusTracking(t *testing.T) {
483396 assert .Equal (t , types .StateSucceeded , appInstall .Components [1 ].Status .State )
484397
485398 mockHelmClient .AssertExpectations (t )
486- mockKotsCLI .AssertExpectations (t )
487399 })
488400
489401 t .Run ("Component failure is tracked correctly" , func (t * testing.T ) {
@@ -513,7 +425,7 @@ func TestComponentStatusTracking(t *testing.T) {
513425 require .NoError (t , err )
514426
515427 // Install the charts (should fail)
516- err = manager .Install (t .Context (), installableCharts , kotsv1beta1. ConfigValues {}, nil , "" )
428+ err = manager .Install (t .Context (), installableCharts , nil , "" )
517429 require .Error (t , err )
518430
519431 // Verify that component failure is tracked
0 commit comments