From 2597c03d1555e00dec59830b7de75e7090208e05 Mon Sep 17 00:00:00 2001 From: Slack Coder Date: Wed, 2 Oct 2024 16:49:36 -0500 Subject: config: Use TOML TOML is simple for users, and it is used in notably projects like rustlang. It also provides comments! --- internal/service/mirror_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 internal/service/mirror_test.go (limited to 'internal/service/mirror_test.go') diff --git a/internal/service/mirror_test.go b/internal/service/mirror_test.go new file mode 100644 index 0000000..f9411e2 --- /dev/null +++ b/internal/service/mirror_test.go @@ -0,0 +1,30 @@ +package service + +import ( + "testing" + + "git.server.ky/slackcoder/mirror/internal" + "github.com/BurntSushi/toml" + "github.com/stretchr/testify/require" +) + +func TestMirrorUnmarshalTOML(t *testing.T) { + str := internal.MustTOML(map[string]interface{}{ + "method": "git", + "from": "https://git.taler.net/merchant.git", + "to": "/mirror/merchant", + }) + + exp := Mirror{ + Method: "git", + From: internal.MustURL("https://git.taler.net/merchant.git"), + To: internal.MustURL("/mirror/merchant"), + } + + var s Mirror + + err := toml.Unmarshal([]byte(str), &s) + + require.NoError(t, err) + require.Equal(t, exp.String(), s.String()) +} -- cgit v1.2.3