Files
tinyauth/internal/utils/decoders/env_decoder_test.go
Stavros 1ad862d86c wip
2025-11-04 17:37:40 +02:00

38 lines
877 B
Go

package decoders_test
import (
"testing"
"tinyauth/internal/config"
"tinyauth/internal/utils/decoders"
"gotest.tools/v3/assert"
)
func TestDecodeEnv(t *testing.T) {
// Setup
env := []string{
"TINYAUTH_PROVIDERS_GOOGLE_CLIENTID=google-client-id",
"TINYAUTH_PROVIDERS_GOOGLE_CLIENTSECRET=google-client-secret",
"TINYAUTH_PROVIDERS_GITHUB_CLIENTID=github-client-id",
"TINYAUTH_PROVIDERS_GITHUB_CLIENTSECRET=github-client-secret",
}
expected := config.Providers{
Providers: map[string]config.OAuthServiceConfig{
"google": {
ClientID: "google-client-id",
ClientSecret: "google-client-secret",
},
"github": {
ClientID: "github-client-id",
ClientSecret: "github-client-secret",
},
},
}
// Execute
result, err := decoders.DecodeEnv[config.Providers](env)
assert.NilError(t, err)
assert.DeepEqual(t, result, expected)
}