Test_StartServices() — fiber Function Reference
Architecture documentation for the Test_StartServices() function in services_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD b5f5584e_043a_16ac_32d8_c83aad9c0df3["Test_StartServices()"] a3b050d2_f10a_df85_e082_e3ac664a6a6c["services_test.go"] b5f5584e_043a_16ac_32d8_c83aad9c0df3 -->|defined in| a3b050d2_f10a_df85_e082_e3ac664a6a6c style b5f5584e_043a_16ac_32d8_c83aad9c0df3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
services_test.go lines 218–308
func Test_StartServices(t *testing.T) {
t.Run("no-services", func(t *testing.T) {
app := &App{
configured: Config{
Services: []Service{},
},
state: newState(),
}
err := app.startServices(context.Background())
require.NoError(t, err)
require.Zero(t, app.state.ServicesLen())
})
t.Run("successful-start", func(t *testing.T) {
app := &App{
configured: Config{
Services: []Service{
&mockService{name: "dep1"},
&mockService{name: "dep2"},
},
},
state: newState(),
}
err := app.startServices(context.Background())
require.NoError(t, err)
require.Equal(t, 2, app.state.ServicesLen())
})
t.Run("failed-start", func(t *testing.T) {
app := &App{
configured: Config{
Services: []Service{
&mockService{name: "dep1", startError: errors.New(startErrorMessage + " 1")},
&mockService{name: "dep2", startError: errors.New(startErrorMessage + " 2")},
&mockService{name: "dep3"},
},
},
state: newState(),
}
err := app.startServices(context.Background())
require.Error(t, err)
require.Contains(t, err.Error(), startErrorMessage+" 1")
require.Contains(t, err.Error(), startErrorMessage+" 2")
require.Equal(t, 1, app.state.ServicesLen())
})
t.Run("context", func(t *testing.T) {
t.Run("already-canceled", func(t *testing.T) {
app := &App{
configured: Config{
Services: []Service{
&mockService{name: "dep1"},
},
},
state: newState(),
}
// Create a context that is already canceled
ctx, cancel := context.WithCancel(context.Background())
cancel()
err := app.startServices(ctx)
require.ErrorIs(t, err, context.Canceled)
require.Zero(t, app.state.ServicesLen())
})
t.Run("cancellation", func(t *testing.T) {
// Create a service that takes some time to start
slowDep := &mockService{name: "slow-dep", startDelay: 200 * time.Millisecond}
app := &App{
configured: Config{
Services: []Service{slowDep},
},
state: newState(),
}
// Create a context that will be canceled immediately
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Test_StartServices() do?
Test_StartServices() is a function in the fiber codebase, defined in services_test.go.
Where is Test_StartServices() defined?
Test_StartServices() is defined in services_test.go at line 218.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free