blob: c8e073a7bc2d20548e4945c7addf46c7b25e22b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
package service
import (
"encoding/json"
"testing"
"git.server.ky/slackcoder/mirror/internal"
"github.com/stretchr/testify/require"
)
func mustJSON(arg interface{}) string {
buf, err := json.Marshal(arg)
if err != nil {
panic(err)
}
return string(buf)
}
func TestMirrorUnmarshalJSON(t *testing.T) {
str := mustJSON(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 := json.Unmarshal([]byte(str), &s)
require.NoError(t, err)
require.Equal(t, exp.String(), s.String())
}
|