35 lines
894 B
Go
35 lines
894 B
Go
package testkit
|
|
|
|
import (
|
|
"context"
|
|
|
|
"galaxy/authsession/internal/ports"
|
|
)
|
|
|
|
// StaticConfigProvider is a deterministic ConfigProvider double that returns a
|
|
// preconfigured session-limit value or error.
|
|
type StaticConfigProvider struct {
|
|
// Config stores the configuration returned when Err is nil.
|
|
Config ports.SessionLimitConfig
|
|
|
|
// Err is returned directly from LoadSessionLimit when set.
|
|
Err error
|
|
}
|
|
|
|
// LoadSessionLimit returns the preconfigured session-limit result.
|
|
func (p StaticConfigProvider) LoadSessionLimit(ctx context.Context) (ports.SessionLimitConfig, error) {
|
|
if err := ctx.Err(); err != nil {
|
|
return ports.SessionLimitConfig{}, err
|
|
}
|
|
if p.Err != nil {
|
|
return ports.SessionLimitConfig{}, p.Err
|
|
}
|
|
if err := p.Config.Validate(); err != nil {
|
|
return ports.SessionLimitConfig{}, err
|
|
}
|
|
|
|
return p.Config, nil
|
|
}
|
|
|
|
var _ ports.ConfigProvider = StaticConfigProvider{}
|