-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathnoc_root_certificates_test.go
64 lines (56 loc) · 1.68 KB
/
noc_root_certificates_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
61
62
63
64
package keeper_test
import (
"strconv"
"testing"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"
keepertest "github.com/zigbee-alliance/distributed-compliance-ledger/testutil/keeper"
"github.com/zigbee-alliance/distributed-compliance-ledger/testutil/nullify"
"github.com/zigbee-alliance/distributed-compliance-ledger/x/pki/keeper"
"github.com/zigbee-alliance/distributed-compliance-ledger/x/pki/types"
)
// Prevent strconv unused error.
var _ = strconv.IntSize
func createNNocRootCertificates(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.NocRootCertificates {
items := make([]types.NocRootCertificates, n)
for i := range items {
items[i].Vid = int32(i)
keeper.SetNocRootCertificates(ctx, items[i])
}
return items
}
func TestNocRootCertificatesGet(t *testing.T) {
keeper, ctx := keepertest.PkiKeeper(t, nil)
items := createNNocRootCertificates(keeper, ctx, 10)
for _, item := range items {
rst, found := keeper.GetNocRootCertificates(ctx,
item.Vid,
)
require.True(t, found)
require.Equal(t,
nullify.Fill(&item),
nullify.Fill(&rst),
)
}
}
func TestNocRootCertificatesRemove(t *testing.T) {
keeper, ctx := keepertest.PkiKeeper(t, nil)
items := createNNocRootCertificates(keeper, ctx, 10)
for _, item := range items {
keeper.RemoveNocRootCertificates(ctx,
item.Vid,
)
_, found := keeper.GetNocRootCertificates(ctx,
item.Vid,
)
require.False(t, found)
}
}
func TestNocRootCertificatesGetAll(t *testing.T) {
keeper, ctx := keepertest.PkiKeeper(t, nil)
items := createNNocRootCertificates(keeper, ctx, 10)
require.ElementsMatch(t,
nullify.Fill(items),
nullify.Fill(keeper.GetAllNocRootCertificates(ctx)),
)
}