-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
map_test.go
150 lines (139 loc) · 5.56 KB
/
map_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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package redirector
import (
"strings"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("Map", func() {
It("Should successfully load the map from a CSV/Pipe separated file", func() {
m, err := loadMapCSV(strings.NewReader(`bananapi/Bullseye_current|bananapi/archive/Armbian_21.08.1_Bananapi_bullseye_current_5.10.60.img.xz|Aug 26 2021|332M`))
Expect(err).To(BeNil())
Expect(m["bananapi/Bullseye_current"]).To(Equal("bananapi/archive/Armbian_21.08.1_Bananapi_bullseye_current_5.10.60.img.xz"))
})
It("Should successfully load the map from a JSON file", func() {
data := `{
"assets": [
{
"board_slug": "aml-s9xx-box",
"armbian_version": "23.11.1",
"file_url": "https://dl.armbian.com/aml-s9xx-box/archive/Armbian_23.11.1_Aml-s9xx-box_bookworm_current_6.1.63.img.xz",
"file_updated": "2023-11-30T01:14:49Z",
"file_size": "566235552",
"distro_release": "bookworm",
"kernel_branch": "current",
"image_variant": "server",
"preinstalled_application": "",
"promoted": "true",
"download_repository": "archive",
"file_extension": "img.xz"
}
]
}`
m, err := loadMapJSON(strings.NewReader(data))
Expect(err).To(BeNil())
Expect(m["aml-s9xx-box/Bookworm_current"]).To(Equal("/aml-s9xx-box/archive/Armbian_23.11.1_Aml-s9xx-box_bookworm_current_6.1.63.img.xz"))
})
It("Should successfully load the map from a JSON file, rewriting extension paths as necessary", func() {
data := `{
"assets": [
{
"board_slug": "khadas-vim1",
"file_url": "https://dl.armbian.com/khadas-vim1/archive/Armbian_23.11.1_Khadas-vim1_bookworm_current_6.1.63_xfce_desktop.img.xz",
"file_updated": "2023-11-30T01:06:34Z",
"file_size": "1605260504",
"distro_release": "bookworm",
"kernel_branch": "current",
"image_variant": "xfce",
"preinstalled_application": "",
"promoted": "false",
"download_repository": "archive",
"file_extension": "img.xz"
},
{
"board_slug": "khadas-vim1",
"file_url": "https://dl.armbian.com/khadas-vim1/archive/Armbian_23.11.1_Khadas-vim1_bookworm_current_6.1.63_xfce_desktop.img.xz.sha",
"file_updated": "2023-11-30T01:06:34Z",
"file_size": "1605260504",
"distro_release": "bookworm",
"kernel_branch": "current",
"image_variant": "xfce",
"preinstalled_application": "",
"promoted": "false",
"download_repository": "archive",
"file_extension": "img.xz.sha"
},
{
"board_slug": "khadas-vim1",
"file_url": "https://dl.armbian.com/khadas-vim1/archive/Armbian_23.11.1_Khadas-vim1_bookworm_current_6.1.63_xfce_desktop.img.xz",
"file_updated": "2023-11-30T01:06:34Z",
"file_size": "1605260504",
"distro_release": "bookworm",
"kernel_branch": "current",
"image_variant": "xfce",
"preinstalled_application": "test",
"promoted": "false",
"download_repository": "archive",
"file_extension": "img.xz"
}
]
}`
m, err := loadMapJSON(strings.NewReader(data))
Expect(err).To(BeNil())
Expect(m["khadas-vim1/Bookworm_current_xfce"]).To(Equal("/khadas-vim1/archive/Armbian_23.11.1_Khadas-vim1_bookworm_current_6.1.63_xfce_desktop.img.xz"))
Expect(m["khadas-vim1/Bookworm_current_xfce.sha"]).To(Equal("/khadas-vim1/archive/Armbian_23.11.1_Khadas-vim1_bookworm_current_6.1.63_xfce_desktop.img.xz.sha"))
Expect(m["khadas-vim1/Bookworm_current_xfce-test"]).To(Equal("/khadas-vim1/archive/Armbian_23.11.1_Khadas-vim1_bookworm_current_6.1.63_xfce_desktop.img.xz"))
})
It("Should work with files that have weird extensions", func() {
data := `{
"assets": [
{
"board_slug": "khadas-vim4",
"armbian_version": "23.11.1",
"file_url": "https://dl.armbian.com/khadas-vim4/archive/Armbian_23.11.1_Khadas-vim4_bookworm_legacy_5.4.180.oowow.img.xz",
"file_updated": "2023-11-30T01:03:05Z",
"file_size": "477868032",
"distro_release": "bookworm",
"kernel_branch": "legacy",
"image_variant": "server",
"preinstalled_application": "",
"promoted": "true",
"download_repository": "archive",
"file_extension": "oowow.img.xz"
},
{
"board_slug": "khadas-vim4",
"armbian_version": "23.11.1",
"file_url": "https://dl.armbian.com/khadas-vim4/archive/Armbian_23.11.1_Khadas-vim4_bookworm_legacy_5.4.180.oowow.img.xz.asc",
"file_updated": "2023-11-30T01:03:05Z",
"file_size": "833",
"distro_release": "bookworm",
"kernel_branch": "legacy",
"image_variant": "server",
"preinstalled_application": "",
"promoted": "true",
"download_repository": "archive",
"file_extension": "oowow.img.xz.asc"
},
{
"board_slug": "khadas-vim4",
"armbian_version": "23.11.1",
"file_url": "https://dl.armbian.com/khadas-vim4/archive/Armbian_23.11.1_Khadas-vim4_bookworm_legacy_5.4.180.oowow.img.xz.sha",
"file_updated": "2023-11-30T01:03:05Z",
"file_size": "178",
"distro_release": "bookworm",
"kernel_branch": "legacy",
"image_variant": "server",
"preinstalled_application": "",
"promoted": "true",
"download_repository": "archive",
"file_extension": "oowow.img.xz.sha"
}
]
}`
m, err := loadMapJSON(strings.NewReader(data))
Expect(err).To(BeNil())
Expect(m["khadas-vim4/Bookworm_legacy"]).To(Equal("/khadas-vim4/archive/Armbian_23.11.1_Khadas-vim4_bookworm_legacy_5.4.180.oowow.img.xz"))
Expect(m["khadas-vim4/Bookworm_legacy.asc"]).To(Equal("/khadas-vim4/archive/Armbian_23.11.1_Khadas-vim4_bookworm_legacy_5.4.180.oowow.img.xz.asc"))
Expect(m["khadas-vim4/Bookworm_legacy.sha"]).To(Equal("/khadas-vim4/archive/Armbian_23.11.1_Khadas-vim4_bookworm_legacy_5.4.180.oowow.img.xz.sha"))
})
})