-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupgrader_test.go
92 lines (85 loc) · 2.5 KB
/
upgrader_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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package worldupgrader
import (
"github.com/df-mc/worldupgrader/blockupgrader"
"github.com/df-mc/worldupgrader/itemupgrader"
"github.com/stretchr/testify/assert"
"testing"
)
func TestBlockUpgrader(t *testing.T) {
state := blockupgrader.BlockState{
Name: "minecraft:wool",
Properties: map[string]any{
"color": "red",
},
Version: 17825806,
}
upgraded := blockupgrader.Upgrade(state)
assert.Equal(t, "minecraft:red_wool", upgraded.Name)
assert.Equal(t, map[string]any{}, upgraded.Properties)
assert.Equal(t, int32(18040335), upgraded.Version)
}
func TestBlockCopiedProperties(t *testing.T) {
state := blockupgrader.BlockState{
Name: "minecraft:log",
Properties: map[string]any{
"old_log_type": "spruce",
"pillar_axis": "y",
},
Version: 17825806,
}
upgraded := blockupgrader.Upgrade(state)
assert.Equal(t, "minecraft:spruce_log", upgraded.Name)
assert.Equal(t, map[string]any{
"pillar_axis": "y",
}, upgraded.Properties)
assert.Equal(t, int32(18042891), upgraded.Version)
}
func TestBlockRemappedPropertyValues(t *testing.T) {
state := blockupgrader.BlockState{
Name: "minecraft:big_dripleaf",
Properties: map[string]any{
"big_dripleaf_head": byte(1),
"big_dripleaf_tilt": "none",
"direction": int32(2),
},
Version: 18090528,
}
upgraded := blockupgrader.Upgrade(state)
assert.Equal(t, "minecraft:big_dripleaf", upgraded.Name)
assert.Equal(t, map[string]any{
"big_dripleaf_head": byte(1),
"big_dripleaf_tilt": "none",
"minecraft:cardinal_direction": "north",
}, upgraded.Properties)
assert.Equal(t, int32(18095666), upgraded.Version)
}
func TestBlockFlattenedValueRemap(t *testing.T) {
state := blockupgrader.BlockState{
Name: "minecraft:wool",
Properties: map[string]any{
"color": "silver",
},
Version: 17825806,
}
upgraded := blockupgrader.Upgrade(state)
assert.Equal(t, "minecraft:light_gray_wool", upgraded.Name)
assert.Equal(t, map[string]any{}, upgraded.Properties)
assert.Equal(t, int32(18040335), upgraded.Version)
}
func TestItemRenamedID(t *testing.T) {
item := itemupgrader.ItemMeta{
Name: "minecraft:record_relic",
}
upgraded := itemupgrader.Upgrade(item)
assert.Equal(t, "minecraft:music_disc_relic", upgraded.Name)
assert.Equal(t, int16(0), upgraded.Meta)
}
func TestItemRemappedMeta(t *testing.T) {
item := itemupgrader.ItemMeta{
Name: "minecraft:concrete",
Meta: 13,
}
upgraded := itemupgrader.Upgrade(item)
assert.Equal(t, "minecraft:green_concrete", upgraded.Name)
assert.Equal(t, int16(0), upgraded.Meta)
}