@@ -132,7 +132,9 @@ func Test_InitServices(t *testing.T) {
132132 require .NotPanics (t , app .initServices )
133133 })
134134
135- t .Run ("successful-start" , func (t * testing.T ) {
135+ t .Run ("start/success" , func (t * testing.T ) {
136+ // Initialize the app using the struct and defining the state and hooks manually,
137+ // because we are not checking the shutdown hooks in this test.
136138 app := & App {
137139 configured : Config {
138140 Services : []Service {
@@ -148,7 +150,9 @@ func Test_InitServices(t *testing.T) {
148150 require .NotPanics (t , app .initServices )
149151 })
150152
151- t .Run ("failed-start" , func (t * testing.T ) {
153+ t .Run ("start/error" , func (t * testing.T ) {
154+ // Initialize the app using the struct and defining the state and hooks manually,
155+ // because we are not checking the shutdown hooks in this test.
152156 app := & App {
153157 configured : Config {
154158 Services : []Service {
@@ -166,14 +170,11 @@ func Test_InitServices(t *testing.T) {
166170 })
167171
168172 t .Run ("shutdown-hooks/success" , func (t * testing.T ) {
169- app := & App {
170- configured : Config {
171- Services : []Service {& mockService {name : "dep1" }},
172- },
173- state : newState (),
174- }
175-
176- app .hooks = newHooks (app )
173+ // Initialize the app using the New function to verify that the shutdown hooks are registered
174+ // and the app mutex is not causing a deadlock.
175+ app := New (Config {
176+ Services : []Service {& mockService {name : "dep1" }},
177+ })
177178
178179 require .NotPanics (t , app .initServices )
179180
@@ -190,17 +191,14 @@ func Test_InitServices(t *testing.T) {
190191 })
191192
192193 t .Run ("shutdown-hooks/error" , func (t * testing.T ) {
193- app := & App {
194- configured : Config {
195- Services : [] Service {
196- & mockService { name : "dep1" },
197- & mockService {name : "dep2" , terminateError : errors . New ( terminateErrorMessage + " 2" ) },
198- },
194+ // Initialize the app using the New function to verify that the shutdown hooks are registered
195+ // and the app mutex is not causing a deadlock.
196+ app := New ( Config {
197+ Services : [] Service {
198+ & mockService {name : "dep1" },
199+ & mockService { name : "dep2" , terminateError : errors . New ( terminateErrorMessage + " 2" ) },
199200 },
200- state : newState (),
201- }
202-
203- app .hooks = newHooks (app )
201+ })
204202
205203 require .NotPanics (t , app .initServices )
206204
0 commit comments