mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-09-17 16:39:04 +02:00
26 lines
648 B
Go
26 lines
648 B
Go
//go:build unit
|
|
|
|
// This file contains utils for unit tests and it's only built when the "unit" tag is set
|
|
package appconfig
|
|
|
|
import (
|
|
"sync/atomic"
|
|
|
|
"github.com/pocket-id/pocket-id/backend/internal/model"
|
|
)
|
|
|
|
// NewTestAppConfigService is a function used by tests to create AppConfigService objects with pre-defined configuration values
|
|
func NewTestAppConfigService(config *model.AppConfig) *AppConfigService {
|
|
if config == nil {
|
|
// If there's no config, set the default one
|
|
config = getDefaultDbConfig()
|
|
}
|
|
|
|
service := &AppConfigService{
|
|
dbConfig: atomic.Pointer[model.AppConfig]{},
|
|
}
|
|
service.dbConfig.Store(config)
|
|
|
|
return service
|
|
}
|