@@ -848,6 +848,81 @@ func TestGetImageRequests_BlueprintDistro(t *testing.T) {
848
848
assert .Equal (t , got [0 ].blueprint .Distro , "fedora-39" )
849
849
}
850
850
851
+ // TestGetImageRequests_BlueprintArchEmpty test blueprint with no arch
852
+ func TestGetImageRequests_BlueprintArchEmpty (t * testing.T ) {
853
+ uo := UploadOptions (struct {}{})
854
+ request := & ComposeRequest {
855
+ Distribution : "fedora-40" ,
856
+ ImageRequest : & ImageRequest {
857
+ Architecture : "x86_64" ,
858
+ ImageType : ImageTypesAws ,
859
+ UploadOptions : & uo ,
860
+ Repositories : []Repository {},
861
+ },
862
+ Blueprint : & Blueprint {
863
+ Name : "arch-test" ,
864
+ },
865
+ }
866
+ // NOTE: current directory is the location of this file, back up so it can use ./repositories/
867
+ rr , err := reporegistry .New ([]string {"../../../" })
868
+ require .NoError (t , err )
869
+ got , err := request .GetImageRequests (distrofactory .NewDefault (), rr )
870
+ assert .NoError (t , err )
871
+ require .Len (t , got , 1 )
872
+ require .Greater (t , len (got [0 ].repositories ), 0 )
873
+ assert .Equal (t , got [0 ].imageType .Arch ().Name (), "x86_64" )
874
+ }
875
+
876
+ // TestGetImageRequests_BlueprintArch test to make sure matching arch works
877
+ func TestGetImageRequests_BlueprintArch (t * testing.T ) {
878
+ uo := UploadOptions (struct {}{})
879
+ request := & ComposeRequest {
880
+ Distribution : "fedora-40" ,
881
+ ImageRequest : & ImageRequest {
882
+ Architecture : "x86_64" ,
883
+ ImageType : ImageTypesAws ,
884
+ UploadOptions : & uo ,
885
+ Repositories : []Repository {},
886
+ },
887
+ Blueprint : & Blueprint {
888
+ Name : "arch-test" ,
889
+ Architecture : common .ToPtr ("x86_64" ),
890
+ },
891
+ }
892
+ // NOTE: current directory is the location of this file, back up so it can use ./repositories/
893
+ rr , err := reporegistry .New ([]string {"../../../" })
894
+ require .NoError (t , err )
895
+ got , err := request .GetImageRequests (distrofactory .NewDefault (), rr )
896
+ assert .NoError (t , err )
897
+ require .Len (t , got , 1 )
898
+ require .Greater (t , len (got [0 ].repositories ), 0 )
899
+ assert .Equal (t , got [0 ].imageType .Arch ().Name (), "x86_64" )
900
+ }
901
+
902
+ // TestGetImageRequests_BlueprintArchError test to make sure mismatched arch returns error
903
+ func TestGetImageRequests_BlueprintArchError (t * testing.T ) {
904
+ uo := UploadOptions (struct {}{})
905
+ request := & ComposeRequest {
906
+ Distribution : "fedora-40" ,
907
+ ImageRequest : & ImageRequest {
908
+ Architecture : "x86_64" ,
909
+ ImageType : ImageTypesAws ,
910
+ UploadOptions : & uo ,
911
+ Repositories : []Repository {},
912
+ },
913
+ Blueprint : & Blueprint {
914
+ Name : "arch-test" ,
915
+ Architecture : common .ToPtr ("aarch64" ),
916
+ },
917
+ }
918
+ // NOTE: current directory is the location of this file, back up so it can use ./repositories/
919
+ rr , err := reporegistry .New ([]string {"../../../" })
920
+ require .NoError (t , err )
921
+ _ , err = request .GetImageRequests (distrofactory .NewDefault (), rr )
922
+ require .Error (t , err )
923
+ assert .Equal (t , HTTPError (ErrorMismatchedArchitecture ), err )
924
+ }
925
+
851
926
func TestOpenSCAPTailoringOptions (t * testing.T ) {
852
927
cr := ComposeRequest {
853
928
Customizations : & Customizations {
0 commit comments