Files
config/provider/handler/env_test.go
andrey 57c035d72e
All checks were successful
Go Action / goaction (pull_request) Successful in 1m3s
update env processor
2025-12-31 23:03:30 +03:00

35 lines
705 B
Go

package handler_test
import (
"context"
"testing"
"gitoa.ru/go-4devs/config"
"gitoa.ru/go-4devs/config/provider/handler"
"gitoa.ru/go-4devs/config/test/require"
"gitoa.ru/go-4devs/config/value"
)
type provider struct {
value config.Value
}
func (p provider) Value(context.Context, ...string) (config.Value, error) {
return p.value, nil
}
func (p provider) Name() string {
return "test"
}
func TestEnvValue(t *testing.T) {
const except = "env value"
t.Setenv("APP_ENV", except)
ctx := context.Background()
process := handler.Env(provider{value: value.String("%env(APP_ENV)%")})
data, err := process.Value(ctx, "any")
require.NoError(t, err)
require.Equal(t, except, data.String())
}