-
Notifications
You must be signed in to change notification settings - Fork 1
/
site_test.go
60 lines (57 loc) · 1.25 KB
/
site_test.go
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package monta
import (
"encoding/json"
"strings"
"testing"
"gotest.tools/v3/assert"
)
func TestSite_MarshalJSON(t *testing.T) {
expected := strings.TrimSpace(`
{
"id": 1,
"name": "Monta CPH HQ",
"chargePointCount": 42,
"activeChargePointCount": 33,
"availableChargePointCount": 4,
"maxKW": 150,
"type": "ac",
"visibility": "public",
"note": "In order to access this site enter 0000 as code at the gate.",
"partnerExternalId": "abc",
"location": {
"coordinates": {
"latitude": 55.6760968,
"longitude": 12.5683371
},
"address": {
"address1": "Strandboulevarden 122",
"address2": "København",
"address3": "5. sal",
"zip": "2100",
"city": "Copenhagen",
"country": "Denmark"
}
},
"connectors": [
{
"identifier": "ccs",
"name": "CCS"
}
],
"createdAt": "2022-05-12T15:56:45.999189Z",
"updatedAt": "2022-05-17T15:56:45.999189Z",
"operator": {
"id": 445,
"name": "Einride",
"identifier": "einride",
"vatNumber": "123",
"partnerId": 423
}
}
`)
var site Site
assert.NilError(t, json.Unmarshal([]byte(expected), &site))
actual, err := json.MarshalIndent(&site, "", " ")
assert.NilError(t, err)
assert.Equal(t, expected, string(actual))
}