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 +++++------------------------ go.mod | 2 +- 2 files changed, 6 insertions(+), 25 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) } diff --git a/go.mod b/go.mod index 1359971..41e3533 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module go.awhk.org/fwdsms -go 1.15 +go 1.16 require ( github.com/gorilla/handlers v1.5.1 -- cgit v1.3