mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-31 22:23:14 +02:00
39 lines
618 B
Go
39 lines
618 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestConfigEnvSubstitution(t *testing.T) {
|
|
os.Setenv("CLOUDFLARE_AUTH_TOKEN", "test")
|
|
readFile = func(_ string) ([]byte, error) {
|
|
return []byte(`
|
|
---
|
|
autocert:
|
|
email: "test@test.com"
|
|
domains:
|
|
- "*.test.com"
|
|
provider: cloudflare
|
|
options:
|
|
auth_token: ${CLOUDFLARE_AUTH_TOKEN}
|
|
`), nil
|
|
}
|
|
|
|
var cfg Config
|
|
out, err := cfg.readConfigFile()
|
|
require.NoError(t, err)
|
|
require.Equal(t, `
|
|
---
|
|
autocert:
|
|
email: "test@test.com"
|
|
domains:
|
|
- "*.test.com"
|
|
provider: cloudflare
|
|
options:
|
|
auth_token: "test"
|
|
`, string(out))
|
|
}
|