@@ -53,6 +53,16 @@ func TestInstNameFromImageURL(t *testing.T) {
5353 name := limatmpl .InstNameFromImageURL (image , arch )
5454 assert .Equal (t , name , "linux" )
5555 })
56+ t .Run ("removes native arch aliases" , func (t * testing.T ) {
57+ arch := limatype .NewArch (runtime .GOARCH )
58+ alias := runtime .GOARCH
59+ if arch == alias {
60+ t .Skip ("no alias for native arch" )
61+ }
62+ image := fmt .Sprintf ("linux-%s.raw" , alias )
63+ name := limatmpl .InstNameFromImageURL (image , arch )
64+ assert .Equal (t , name , "linux" )
65+ })
5666 t .Run ("removes redundant major version" , func (t * testing.T ) {
5767 name := limatmpl .InstNameFromImageURL ("rocky-8-8.10.raw" , "unknown" )
5868 assert .Equal (t , name , "rocky-8.10" )
@@ -144,61 +154,51 @@ func TestRead(t *testing.T) {
144154 tests := []struct {
145155 name string
146156 locator string
147- expectedName string
148157 expectedOS limatype.OS
149158 expectedArch limatype.Arch
150159 }{
151160 {
152161 locator : "http://ftp-archive.freebsd.org/pub/FreeBSD-Archive/old-releases/VM-IMAGES/15.0-RELEASE/amd64/Latest/FreeBSD-15.0-RELEASE-amd64-BASIC-CLOUDINIT-zfs.raw.xz" ,
153- expectedName : "freebsd-15.0-amd64-zfs" ,
154162 expectedOS : limatype .FREEBSD ,
155163 expectedArch : limatype .X8664 ,
156164 },
157165 {
158166 locator : "https://download.freebsd.org/ftp/snapshots/VM-IMAGES/16.0-CURRENT/aarch64/Latest/FreeBSD-16.0-CURRENT-arm64-aarch64-BASIC-CLOUDINIT-ufs.qcow2.xz" ,
159- expectedName : "freebsd-16.0-arm64-ufs" ,
160167 expectedOS : limatype .FREEBSD ,
161168 expectedArch : limatype .AARCH64 ,
162169 },
163170 {
164171 locator : "https://updates.cdn-apple.com/2025SummerFCS/fullrestores/093-10809/CFD6DD38-DAF0-40DA-854F-31AAD1294C6F/UniversalMac_15.6.1_24G90_Restore.ipsw" ,
165- expectedName : "macos-15.6.1" ,
166172 expectedOS : limatype .DARWIN ,
167173 expectedArch : limatype .AARCH64 ,
168174 },
169175 {
170176 locator : "https://updates.cdn-apple.com/2026WinterFCS/fullrestores/047-60229/6D5DBEA5-75A0-4BEF-ACC9-5ACF9B8DF6B7/UniversalMac_26.3_25D125_Restore.ipsw" ,
171- expectedName : "macos-26.3" ,
172177 expectedOS : limatype .DARWIN ,
173178 expectedArch : limatype .AARCH64 ,
174179 },
175180 {
176181 locator : "file:///somewhere/macOS-26.ipsw" ,
177- expectedName : "macos-26" ,
178182 expectedOS : limatype .DARWIN ,
179183 expectedArch : limatype .AARCH64 ,
180184 },
181185 {
182186 locator : "file:///somewhere/my-custom-macos.img" ,
183- expectedName : "my-custom-macos" ,
184187 expectedOS : limatype .DARWIN ,
185188 expectedArch : limatype .AARCH64 ,
186189 },
187190 {
188191 locator : "file:///somewhere/something.ipsw" ,
189- expectedName : "something" ,
190192 expectedOS : limatype .DARWIN ,
191193 expectedArch : limatype .AARCH64 ,
192194 },
193195 {
194196 locator : "https://cloud-images.ubuntu.com/releases/noble/release-20260209/ubuntu-24.04-server-cloudimg-amd64.img" ,
195- expectedName : "ubuntu-24.04-amd64" ,
196197 expectedOS : limatype .LINUX ,
197198 expectedArch : limatype .X8664 ,
198199 },
199200 {
200201 locator : "https://cloud-images.ubuntu.com/releases/noble/release-20260209/ubuntu-24.04-server-cloudimg-arm64.img" ,
201- expectedName : "ubuntu-24.04-arm64" ,
202202 expectedOS : limatype .LINUX ,
203203 expectedArch : limatype .AARCH64 ,
204204 },
@@ -207,7 +207,6 @@ func TestRead(t *testing.T) {
207207 t .Run (tt .locator , func (t * testing.T ) {
208208 tmpl , err := limatmpl .Read (t .Context (), "" , tt .locator )
209209 assert .NilError (t , err )
210- assert .Equal (t , tmpl .Name , tt .expectedName )
211210 err = tmpl .Unmarshal ()
212211 assert .NilError (t , err )
213212 assert .Assert (t , tmpl .Config .OS != nil , "os must be set" )
0 commit comments