diff options
| author | Grégoire Duchêne <gduchene@awhk.org> | 2021-07-04 17:24:16 +0100 |
|---|---|---|
| committer | Grégoire Duchêne <gduchene@awhk.org> | 2021-07-04 17:24:54 +0100 |
| commit | e9ccaea8c006eb1e2d8365352f7380cd79966888 (patch) | |
| tree | 7649fae69d5f42c4a6c6637ad60259ffee394f55 /config_test.go | |
| parent | d95e8ce75cc193181fd8cf9272269fbfff911f66 (diff) | |
Embed config_example.yaml in test code
Diffstat (limited to 'config_test.go')
| -rw-r--r-- | config_test.go | 29 |
1 files changed, 5 insertions, 24 deletions
diff --git a/config_test.go b/config_test.go index a303719..0ab881a 100644 --- a/config_test.go +++ b/config_test.go @@ -1,36 +1,17 @@ package main import ( - "strings" + "bytes" + _ "embed" "testing" "github.com/stretchr/testify/assert" ) -const cfg string = ` -message: - from: foo@example.com - to: bar@example.com - subject: New SMS From {{.From}} For {{.To}} - template: | - From: {{.From}} - To: {{.To}} - Date: {{.DateReceived.UTC}} - - {{.Message}} - -smtp: - hostname: example.com:465 - username: bar - password: some password - -twilio: - address: /run/fwdsms/socket - authToken: some token - endpoint: / -` +//go:embed config_example.yaml +var cfg []byte func TestConfig(t *testing.T) { - _, err := loadConfig(strings.NewReader(cfg)) + _, err := loadConfig(bytes.NewReader(cfg)) assert.NoError(t, err) } |
