-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdid_groups_test.go
More file actions
84 lines (68 loc) · 3.14 KB
/
Copy pathdid_groups_test.go
File metadata and controls
84 lines (68 loc) · 3.14 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package didww
import (
"context"
"net/http"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestDIDGroupsList(t *testing.T) {
_, client := newTestServer(t, map[string]testRoute{
"GET /v3/did_groups": {status: http.StatusOK, fixture: "did_groups/index.json"},
})
groups, err := client.DIDGroups().List(context.Background(), nil)
require.NoError(t, err)
require.NotEmpty(t, groups)
}
func TestDIDGroupsFindWithIncludes(t *testing.T) {
_, client := newTestServer(t, map[string]testRoute{
"GET /v3/did_groups/2187c36d-28fb-436f-8861-5a0f5b5a3ee1": {status: http.StatusOK, fixture: "did_groups/show.json"},
})
params := NewQueryParams().Include("country,city,did_group_type,stock_keeping_units")
group, err := client.DIDGroups().Find(context.Background(), "2187c36d-28fb-436f-8861-5a0f5b5a3ee1", params)
require.NoError(t, err)
assert.Equal(t, "2187c36d-28fb-436f-8861-5a0f5b5a3ee1", group.ID)
assert.Equal(t, "241", group.Prefix)
assert.Equal(t, "Aachen", group.AreaName)
assert.True(t, group.AllowAdditionalChannels)
// Verify included country
require.NotNil(t, group.Country)
assert.Equal(t, "Germany", group.Country.Name)
assert.Equal(t, "DE", group.Country.ISO)
// Verify included city
require.NotNil(t, group.City)
assert.Equal(t, "Aachen", group.City.Name)
// Verify included DID group type
require.NotNil(t, group.DIDGroupType)
assert.Equal(t, "Local", group.DIDGroupType.Name)
// Verify included stock keeping units
require.Len(t, group.StockKeepingUnits, 2)
assert.Equal(t, "0.4", group.StockKeepingUnits[0].SetupPrice)
assert.Equal(t, "0.8", group.StockKeepingUnits[0].MonthlyPrice)
assert.Equal(t, 0, group.StockKeepingUnits[0].ChannelsIncludedCount)
assert.Equal(t, 2, group.StockKeepingUnits[1].ChannelsIncludedCount)
}
func TestDIDGroupsFindWithIncludedRequirement(t *testing.T) {
_, client := newTestServer(t, map[string]testRoute{
"GET /v3/did_groups/2187c36d-28fb-436f-8861-5a0f5b5a3ee1": {status: http.StatusOK, fixture: "did_groups/show_with_requirement.json"},
})
params := NewQueryParams().Include("address_requirement")
group, err := client.DIDGroups().Find(context.Background(), "2187c36d-28fb-436f-8861-5a0f5b5a3ee1", params)
require.NoError(t, err)
assert.Equal(t, "2187c36d-28fb-436f-8861-5a0f5b5a3ee1", group.ID)
assert.Equal(t, "241", group.Prefix)
assert.Equal(t, "Aachen", group.AreaName)
assert.False(t, group.IsMetered)
assert.True(t, group.AllowAdditionalChannels)
// Verify included address_requirement
require.NotNil(t, group.AddressRequirement)
assert.Equal(t, "8da1e0b2-047c-4baf-9c57-57143f09b9ce", group.AddressRequirement.ID)
assert.Equal(t, "any", group.AddressRequirement.IdentityType)
assert.Equal(t, "world_wide", group.AddressRequirement.PersonalAreaLevel)
assert.Equal(t, "country", group.AddressRequirement.BusinessAreaLevel)
assert.Equal(t, "city", group.AddressRequirement.AddressAreaLevel)
assert.Equal(t, 1, group.AddressRequirement.PersonalProofQty)
assert.Equal(t, 1, group.AddressRequirement.BusinessProofQty)
assert.Equal(t, 1, group.AddressRequirement.AddressProofQty)
assert.False(t, group.AddressRequirement.ServiceDescriptionRequired)
}