fix(i18n): keep default state snapshot explicit
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
56b6db8a8d
commit
fdb151a0af
2 changed files with 9 additions and 2 deletions
5
i18n.go
5
i18n.go
|
|
@ -180,9 +180,10 @@ func CurrentDebug() bool {
|
|||
|
||||
// State returns a copy-safe snapshot of the default service configuration.
|
||||
func State() ServiceState {
|
||||
return defaultServiceValue(defaultServiceStateSnapshot(), func(svc *Service) ServiceState {
|
||||
if svc := Default(); svc != nil {
|
||||
return svc.State()
|
||||
})
|
||||
}
|
||||
return defaultServiceStateSnapshot()
|
||||
}
|
||||
|
||||
// CurrentState is a more explicit alias for State.
|
||||
|
|
|
|||
|
|
@ -261,6 +261,12 @@ func TestCurrentState_Good(t *testing.T) {
|
|||
assert.NotNil(t, CurrentState().Handlers[0])
|
||||
}
|
||||
|
||||
func TestState_Good_WithoutDefaultService(t *testing.T) {
|
||||
var svc *Service
|
||||
state := svc.State()
|
||||
assert.Equal(t, defaultServiceStateSnapshot(), state)
|
||||
}
|
||||
|
||||
// --- SetMode / CurrentMode ---
|
||||
|
||||
func TestSetMode_Good(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue