From e9ccaea8c006eb1e2d8365352f7380cd79966888 Mon Sep 17 00:00:00 2001 From: GrĂ©goire DuchĂȘne Date: Sun, 4 Jul 2021 17:24:16 +0100 Subject: Embed config_example.yaml in test code --- config_test.go | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) (limited to 'config_test.go') 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) } -- cgit v1.2.3-70-g09d2