fix startup bootstrap recovery and local verification
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -83,3 +85,47 @@ func TestProvideCleanup_WithMinimalDependencies_NoPanic(t *testing.T) {
|
||||
cleanup()
|
||||
})
|
||||
}
|
||||
|
||||
func TestNewBootstrapFunc_RunsDefaultsBeforeRecovery(t *testing.T) {
|
||||
cfg := &config.Config{}
|
||||
order := make([]string, 0, 2)
|
||||
|
||||
bootstrap := newBootstrapFunc(
|
||||
func(context.Context) error {
|
||||
order = append(order, "defaults")
|
||||
return nil
|
||||
},
|
||||
func(_ context.Context, gotRepo service.UserRepository, got *config.Config) error {
|
||||
require.Nil(t, gotRepo)
|
||||
require.Same(t, cfg, got)
|
||||
order = append(order, "recover")
|
||||
return nil
|
||||
},
|
||||
nil,
|
||||
cfg,
|
||||
)
|
||||
|
||||
require.NoError(t, bootstrap())
|
||||
require.Equal(t, []string{"defaults", "recover"}, order)
|
||||
}
|
||||
|
||||
func TestNewBootstrapFunc_StopsWhenDefaultsFail(t *testing.T) {
|
||||
cfg := &config.Config{}
|
||||
wantErr := errors.New("defaults failed")
|
||||
recoverCalled := false
|
||||
|
||||
bootstrap := newBootstrapFunc(
|
||||
func(context.Context) error {
|
||||
return wantErr
|
||||
},
|
||||
func(context.Context, service.UserRepository, *config.Config) error {
|
||||
recoverCalled = true
|
||||
return nil
|
||||
},
|
||||
nil,
|
||||
cfg,
|
||||
)
|
||||
|
||||
require.ErrorIs(t, bootstrap(), wantErr)
|
||||
require.False(t, recoverCalled)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user