66 "time"
77
88 appconfig "github.com/replicatedhq/embedded-cluster/api/internal/managers/app/config"
9+ apppreflightmanager "github.com/replicatedhq/embedded-cluster/api/internal/managers/app/preflight"
10+ appreleasemanager "github.com/replicatedhq/embedded-cluster/api/internal/managers/app/release"
911 "github.com/replicatedhq/embedded-cluster/api/internal/statemachine"
1012 states "github.com/replicatedhq/embedded-cluster/api/internal/states/install"
1113 "github.com/replicatedhq/embedded-cluster/api/types"
@@ -37,10 +39,10 @@ func (s *AppInstallControllerTestSuite) TestPatchAppConfigValues() {
3739 },
3840 currentState : states .StateNew ,
3941 expectedState : states .StateApplicationConfigured ,
40- setupMocks : func (am * appconfig.MockAppConfigManager ) {
42+ setupMocks : func (acm * appconfig.MockAppConfigManager ) {
4143 mock .InOrder (
42- am .On ("ValidateConfigValues" , types.AppConfigValues {"test-item" : types.AppConfigValue {Value : "new-item" }}).Return (nil ),
43- am .On ("PatchConfigValues" , types.AppConfigValues {"test-item" : types.AppConfigValue {Value : "new-item" }}).Return (nil ),
44+ acm .On ("ValidateConfigValues" , types.AppConfigValues {"test-item" : types.AppConfigValue {Value : "new-item" }}).Return (nil ),
45+ acm .On ("PatchConfigValues" , types.AppConfigValues {"test-item" : types.AppConfigValue {Value : "new-item" }}).Return (nil ),
4446 )
4547 },
4648 expectedErr : false ,
@@ -52,10 +54,10 @@ func (s *AppInstallControllerTestSuite) TestPatchAppConfigValues() {
5254 },
5355 currentState : states .StateApplicationConfigurationFailed ,
5456 expectedState : states .StateApplicationConfigured ,
55- setupMocks : func (am * appconfig.MockAppConfigManager ) {
57+ setupMocks : func (acm * appconfig.MockAppConfigManager ) {
5658 mock .InOrder (
57- am .On ("ValidateConfigValues" , types.AppConfigValues {"test-item" : types.AppConfigValue {Value : "new-item" }}).Return (nil ),
58- am .On ("PatchConfigValues" , types.AppConfigValues {"test-item" : types.AppConfigValue {Value : "new-item" }}).Return (nil ),
59+ acm .On ("ValidateConfigValues" , types.AppConfigValues {"test-item" : types.AppConfigValue {Value : "new-item" }}).Return (nil ),
60+ acm .On ("PatchConfigValues" , types.AppConfigValues {"test-item" : types.AppConfigValue {Value : "new-item" }}).Return (nil ),
5961 )
6062 },
6163 expectedErr : false ,
@@ -67,10 +69,10 @@ func (s *AppInstallControllerTestSuite) TestPatchAppConfigValues() {
6769 },
6870 currentState : states .StateApplicationConfigured ,
6971 expectedState : states .StateApplicationConfigured ,
70- setupMocks : func (am * appconfig.MockAppConfigManager ) {
72+ setupMocks : func (acm * appconfig.MockAppConfigManager ) {
7173 mock .InOrder (
72- am .On ("ValidateConfigValues" , types.AppConfigValues {"test-item" : types.AppConfigValue {Value : "new-item" }}).Return (nil ),
73- am .On ("PatchConfigValues" , types.AppConfigValues {"test-item" : types.AppConfigValue {Value : "new-item" }}).Return (nil ),
74+ acm .On ("ValidateConfigValues" , types.AppConfigValues {"test-item" : types.AppConfigValue {Value : "new-item" }}).Return (nil ),
75+ acm .On ("PatchConfigValues" , types.AppConfigValues {"test-item" : types.AppConfigValue {Value : "new-item" }}).Return (nil ),
7476 )
7577 },
7678 expectedErr : false ,
@@ -82,9 +84,9 @@ func (s *AppInstallControllerTestSuite) TestPatchAppConfigValues() {
8284 },
8385 currentState : states .StateNew ,
8486 expectedState : states .StateApplicationConfigurationFailed ,
85- setupMocks : func (am * appconfig.MockAppConfigManager ) {
87+ setupMocks : func (acm * appconfig.MockAppConfigManager ) {
8688 mock .InOrder (
87- am .On ("ValidateConfigValues" , types.AppConfigValues {"test-item" : types.AppConfigValue {Value : "invalid-value" }}).Return (errors .New ("validation error" )),
89+ acm .On ("ValidateConfigValues" , types.AppConfigValues {"test-item" : types.AppConfigValue {Value : "invalid-value" }}).Return (errors .New ("validation error" )),
8890 )
8991 },
9092 expectedErr : true ,
@@ -96,10 +98,10 @@ func (s *AppInstallControllerTestSuite) TestPatchAppConfigValues() {
9698 },
9799 currentState : states .StateNew ,
98100 expectedState : states .StateApplicationConfigurationFailed ,
99- setupMocks : func (am * appconfig.MockAppConfigManager ) {
101+ setupMocks : func (acm * appconfig.MockAppConfigManager ) {
100102 mock .InOrder (
101- am .On ("ValidateConfigValues" , types.AppConfigValues {"test-item" : types.AppConfigValue {Value : "new-item" }}).Return (nil ),
102- am .On ("PatchConfigValues" , types.AppConfigValues {"test-item" : types.AppConfigValue {Value : "new-item" }}).Return (errors .New ("set config error" )),
103+ acm .On ("ValidateConfigValues" , types.AppConfigValues {"test-item" : types.AppConfigValue {Value : "new-item" }}).Return (nil ),
104+ acm .On ("PatchConfigValues" , types.AppConfigValues {"test-item" : types.AppConfigValue {Value : "new-item" }}).Return (errors .New ("set config error" )),
103105 )
104106 },
105107 expectedErr : true ,
@@ -111,7 +113,7 @@ func (s *AppInstallControllerTestSuite) TestPatchAppConfigValues() {
111113 },
112114 currentState : states .StateInfrastructureInstalling ,
113115 expectedState : states .StateInfrastructureInstalling ,
114- setupMocks : func (am * appconfig.MockAppConfigManager ) {
116+ setupMocks : func (acm * appconfig.MockAppConfigManager ) {
115117 },
116118 expectedErr : true ,
117119 },
@@ -120,15 +122,19 @@ func (s *AppInstallControllerTestSuite) TestPatchAppConfigValues() {
120122 for _ , tt := range tests {
121123 s .T ().Run (tt .name , func (t * testing.T ) {
122124
123- manager := & appconfig.MockAppConfigManager {}
125+ appConfigManager := & appconfig.MockAppConfigManager {}
126+ appPreflightManager := & apppreflightmanager.MockAppPreflightManager {}
127+ appReleaseManager := & appreleasemanager.MockAppReleaseManager {}
124128 sm := s .CreateStateMachine (tt .currentState )
125129 controller , err := NewInstallController (
126130 WithStateMachine (sm ),
127- WithAppConfigManager (manager ),
131+ WithAppConfigManager (appConfigManager ),
132+ WithAppPreflightManager (appPreflightManager ),
133+ WithAppReleaseManager (appReleaseManager ),
128134 )
129135 require .NoError (t , err , "failed to create install controller" )
130136
131- tt .setupMocks (manager )
137+ tt .setupMocks (appConfigManager )
132138 err = controller .PatchAppConfigValues (t .Context (), tt .values )
133139
134140 if tt .expectedErr {
@@ -141,7 +147,7 @@ func (s *AppInstallControllerTestSuite) TestPatchAppConfigValues() {
141147 return sm .CurrentState () == tt .expectedState
142148 }, time .Second , 100 * time .Millisecond , "state should be %s but is %s" , tt .expectedState , sm .CurrentState ())
143149 assert .False (t , sm .IsLockAcquired (), "state machine should not be locked after setting app config values" )
144- manager .AssertExpectations (s .T ())
150+ appConfigManager .AssertExpectations (s .T ())
145151
146152 })
147153 }
0 commit comments