-
Notifications
You must be signed in to change notification settings - Fork 3.7k
/
Copy pathstore_test.go
65 lines (60 loc) · 1.52 KB
/
store_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
65
package runtime
import (
"testing"
"github.com/stretchr/testify/require"
corestore "cosmossdk.io/core/store"
)
func TestCheckStoreUpgrade(t *testing.T) {
tests := []struct {
name string
storeUpgrades *corestore.StoreUpgrades
errMsg string
}{
{
name: "Nil StoreUpgrades",
storeUpgrades: nil,
errMsg: "store upgrades cannot be nil",
},
{
name: "Valid StoreUpgrades",
storeUpgrades: &corestore.StoreUpgrades{
Added: []string{"store1", "store2"},
Deleted: []string{"store3", "store4"},
},
},
{
name: "Duplicate key in Added",
storeUpgrades: &corestore.StoreUpgrades{
Added: []string{"store1", "store2", "store1"},
Deleted: []string{"store3"},
},
errMsg: "store upgrade has duplicate key store1 in added",
},
{
name: "Duplicate key in Deleted",
storeUpgrades: &corestore.StoreUpgrades{
Added: []string{"store1"},
Deleted: []string{"store2", "store3", "store2"},
},
errMsg: "store upgrade has duplicate key store2 in deleted",
},
{
name: "Key in both Added and Deleted",
storeUpgrades: &corestore.StoreUpgrades{
Added: []string{"store1", "store2"},
Deleted: []string{"store2", "store3"},
},
errMsg: "store upgrade has key store2 in both added and deleted",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := checkStoreUpgrade(tt.storeUpgrades)
if tt.errMsg == "" {
require.NoError(t, err)
} else {
require.ErrorContains(t, err, tt.errMsg)
}
})
}
}