@@ -988,3 +988,193 @@ test.serial(
988988    t . true ( gitlab . isDone ( ) ) ; 
989989  } 
990990) ; 
991+ 
992+ test . serial ( "Throw SemanticReleaseError if generic package asset label contains spaces" ,  async  ( t )  =>  { 
993+   const  owner  =  "test_user" ; 
994+   const  repo  =  "test_repo" ; 
995+   const  env  =  {  GITLAB_TOKEN : "gitlab_token"  } ; 
996+   const  assets  =  [ {  path : "file.css" ,  label : "Style package" ,  target : "generic_package"  } ] ; 
997+   const  gitlab  =  authenticate ( env ) 
998+     . get ( `/projects/${ owner }  %2F${ repo }  ` ) 
999+     . reply ( 200 ,  {  permissions : {  project_access : {  access_level : 40  }  }  } ) ; 
1000+ 
1001+   const  { 
1002+     errors : [ error ] , 
1003+   }  =  await  t . throwsAsync ( 
1004+     verify ( 
1005+       {  assets } , 
1006+       {  env,  options : {  repositoryUrl : `https://gitlab.com/${ owner }  /${ repo }  .git`  } ,  logger : t . context . logger  } 
1007+     ) 
1008+   ) ; 
1009+   t . is ( error . name ,  "SemanticReleaseError" ) ; 
1010+   t . is ( error . code ,  "EINVALIDGENERICPACKAGELABEL" ) ; 
1011+   t . true ( gitlab . isDone ( ) ) ; 
1012+ } ) ; 
1013+ 
1014+ test . serial ( "Throw SemanticReleaseError if generic package asset label starts with ~" ,  async  ( t )  =>  { 
1015+   const  owner  =  "test_user" ; 
1016+   const  repo  =  "test_repo" ; 
1017+   const  env  =  {  GITLAB_TOKEN : "gitlab_token"  } ; 
1018+   const  assets  =  [ {  path : "file.css" ,  label : "~invalid" ,  target : "generic_package"  } ] ; 
1019+   const  gitlab  =  authenticate ( env ) 
1020+     . get ( `/projects/${ owner }  %2F${ repo }  ` ) 
1021+     . reply ( 200 ,  {  permissions : {  project_access : {  access_level : 40  }  }  } ) ; 
1022+ 
1023+   const  { 
1024+     errors : [ error ] , 
1025+   }  =  await  t . throwsAsync ( 
1026+     verify ( 
1027+       {  assets } , 
1028+       {  env,  options : {  repositoryUrl : `https://gitlab.com/${ owner }  /${ repo }  .git`  } ,  logger : t . context . logger  } 
1029+     ) 
1030+   ) ; 
1031+   t . is ( error . name ,  "SemanticReleaseError" ) ; 
1032+   t . is ( error . code ,  "EINVALIDGENERICPACKAGELABEL" ) ; 
1033+   t . true ( gitlab . isDone ( ) ) ; 
1034+ } ) ; 
1035+ 
1036+ test . serial ( "Throw SemanticReleaseError if generic package asset label starts with @" ,  async  ( t )  =>  { 
1037+   const  owner  =  "test_user" ; 
1038+   const  repo  =  "test_repo" ; 
1039+   const  env  =  {  GITLAB_TOKEN : "gitlab_token"  } ; 
1040+   const  assets  =  [ {  path : "file.css" ,  label : "@invalid" ,  target : "generic_package"  } ] ; 
1041+   const  gitlab  =  authenticate ( env ) 
1042+     . get ( `/projects/${ owner }  %2F${ repo }  ` ) 
1043+     . reply ( 200 ,  {  permissions : {  project_access : {  access_level : 40  }  }  } ) ; 
1044+ 
1045+   const  { 
1046+     errors : [ error ] , 
1047+   }  =  await  t . throwsAsync ( 
1048+     verify ( 
1049+       {  assets } , 
1050+       {  env,  options : {  repositoryUrl : `https://gitlab.com/${ owner }  /${ repo }  .git`  } ,  logger : t . context . logger  } 
1051+     ) 
1052+   ) ; 
1053+   t . is ( error . name ,  "SemanticReleaseError" ) ; 
1054+   t . is ( error . code ,  "EINVALIDGENERICPACKAGELABEL" ) ; 
1055+   t . true ( gitlab . isDone ( ) ) ; 
1056+ } ) ; 
1057+ 
1058+ test . serial ( "Throw SemanticReleaseError if generic package asset label ends with ~" ,  async  ( t )  =>  { 
1059+   const  owner  =  "test_user" ; 
1060+   const  repo  =  "test_repo" ; 
1061+   const  env  =  {  GITLAB_TOKEN : "gitlab_token"  } ; 
1062+   const  assets  =  [ {  path : "file.css" ,  label : "invalid~" ,  target : "generic_package"  } ] ; 
1063+   const  gitlab  =  authenticate ( env ) 
1064+     . get ( `/projects/${ owner }  %2F${ repo }  ` ) 
1065+     . reply ( 200 ,  {  permissions : {  project_access : {  access_level : 40  }  }  } ) ; 
1066+ 
1067+   const  { 
1068+     errors : [ error ] , 
1069+   }  =  await  t . throwsAsync ( 
1070+     verify ( 
1071+       {  assets } , 
1072+       {  env,  options : {  repositoryUrl : `https://gitlab.com/${ owner }  /${ repo }  .git`  } ,  logger : t . context . logger  } 
1073+     ) 
1074+   ) ; 
1075+   t . is ( error . name ,  "SemanticReleaseError" ) ; 
1076+   t . is ( error . code ,  "EINVALIDGENERICPACKAGELABEL" ) ; 
1077+   t . true ( gitlab . isDone ( ) ) ; 
1078+ } ) ; 
1079+ 
1080+ test . serial ( "Throw SemanticReleaseError if generic package asset label ends with @" ,  async  ( t )  =>  { 
1081+   const  owner  =  "test_user" ; 
1082+   const  repo  =  "test_repo" ; 
1083+   const  env  =  {  GITLAB_TOKEN : "gitlab_token"  } ; 
1084+   const  assets  =  [ {  path : "file.css" ,  label : "invalid@" ,  target : "generic_package"  } ] ; 
1085+   const  gitlab  =  authenticate ( env ) 
1086+     . get ( `/projects/${ owner }  %2F${ repo }  ` ) 
1087+     . reply ( 200 ,  {  permissions : {  project_access : {  access_level : 40  }  }  } ) ; 
1088+ 
1089+   const  { 
1090+     errors : [ error ] , 
1091+   }  =  await  t . throwsAsync ( 
1092+     verify ( 
1093+       {  assets } , 
1094+       {  env,  options : {  repositoryUrl : `https://gitlab.com/${ owner }  /${ repo }  .git`  } ,  logger : t . context . logger  } 
1095+     ) 
1096+   ) ; 
1097+   t . is ( error . name ,  "SemanticReleaseError" ) ; 
1098+   t . is ( error . code ,  "EINVALIDGENERICPACKAGELABEL" ) ; 
1099+   t . true ( gitlab . isDone ( ) ) ; 
1100+ } ) ; 
1101+ 
1102+ test . serial ( "Throw SemanticReleaseError if generic package asset label contains invalid characters" ,  async  ( t )  =>  { 
1103+   const  owner  =  "test_user" ; 
1104+   const  repo  =  "test_repo" ; 
1105+   const  env  =  {  GITLAB_TOKEN : "gitlab_token"  } ; 
1106+   const  assets  =  [ {  path : "file.css" ,  label : "invalid$char" ,  target : "generic_package"  } ] ; 
1107+   const  gitlab  =  authenticate ( env ) 
1108+     . get ( `/projects/${ owner }  %2F${ repo }  ` ) 
1109+     . reply ( 200 ,  {  permissions : {  project_access : {  access_level : 40  }  }  } ) ; 
1110+ 
1111+   const  { 
1112+     errors : [ error ] , 
1113+   }  =  await  t . throwsAsync ( 
1114+     verify ( 
1115+       {  assets } , 
1116+       {  env,  options : {  repositoryUrl : `https://gitlab.com/${ owner }  /${ repo }  .git`  } ,  logger : t . context . logger  } 
1117+     ) 
1118+   ) ; 
1119+   t . is ( error . name ,  "SemanticReleaseError" ) ; 
1120+   t . is ( error . code ,  "EINVALIDGENERICPACKAGELABEL" ) ; 
1121+   t . true ( gitlab . isDone ( ) ) ; 
1122+ } ) ; 
1123+ 
1124+ test . serial ( "Does not throw for valid generic package asset labels" ,  async  ( t )  =>  { 
1125+   const  owner  =  "test_user" ; 
1126+   const  repo  =  "test_repo" ; 
1127+   const  env  =  {  GITLAB_TOKEN : "gitlab_token"  } ; 
1128+   const  assets  =  [ 
1129+     {  path : "file.css" ,  label : "valid-label_123.tar.gz" ,  target : "generic_package"  } , 
1130+     {  path : "file2.css" ,  label : "another.valid+label~0" ,  target : "generic_package"  } , 
1131+     {  path : "file3.css" ,  label : "path/to/file" ,  target : "generic_package"  } , 
1132+   ] ; 
1133+   const  gitlab  =  authenticate ( env ) 
1134+     . get ( `/projects/${ owner }  %2F${ repo }  ` ) 
1135+     . reply ( 200 ,  {  permissions : {  project_access : {  access_level : 40  }  }  } ) ; 
1136+ 
1137+   await  t . notThrowsAsync ( 
1138+     verify ( 
1139+       {  assets } , 
1140+       {  env,  options : {  repositoryUrl : `https://gitlab.com/${ owner }  /${ repo }  .git`  } ,  logger : t . context . logger  } 
1141+     ) 
1142+   ) ; 
1143+   t . true ( gitlab . isDone ( ) ) ; 
1144+ } ) ; 
1145+ 
1146+ test . serial ( "Does not throw for generic package assets without labels" ,  async  ( t )  =>  { 
1147+   const  owner  =  "test_user" ; 
1148+   const  repo  =  "test_repo" ; 
1149+   const  env  =  {  GITLAB_TOKEN : "gitlab_token"  } ; 
1150+   const  assets  =  [ {  path : "file.css" ,  target : "generic_package"  } ] ; 
1151+   const  gitlab  =  authenticate ( env ) 
1152+     . get ( `/projects/${ owner }  %2F${ repo }  ` ) 
1153+     . reply ( 200 ,  {  permissions : {  project_access : {  access_level : 40  }  }  } ) ; 
1154+ 
1155+   await  t . notThrowsAsync ( 
1156+     verify ( 
1157+       {  assets } , 
1158+       {  env,  options : {  repositoryUrl : `https://gitlab.com/${ owner }  /${ repo }  .git`  } ,  logger : t . context . logger  } 
1159+     ) 
1160+   ) ; 
1161+   t . true ( gitlab . isDone ( ) ) ; 
1162+ } ) ; 
1163+ 
1164+ test . serial ( "Does not throw for non-generic package assets with spaces in labels" ,  async  ( t )  =>  { 
1165+   const  owner  =  "test_user" ; 
1166+   const  repo  =  "test_repo" ; 
1167+   const  env  =  {  GITLAB_TOKEN : "gitlab_token"  } ; 
1168+   const  assets  =  [ {  path : "file.css" ,  label : "Valid Label With Spaces"  } ] ; 
1169+   const  gitlab  =  authenticate ( env ) 
1170+     . get ( `/projects/${ owner }  %2F${ repo }  ` ) 
1171+     . reply ( 200 ,  {  permissions : {  project_access : {  access_level : 40  }  }  } ) ; 
1172+ 
1173+   await  t . notThrowsAsync ( 
1174+     verify ( 
1175+       {  assets } , 
1176+       {  env,  options : {  repositoryUrl : `https://gitlab.com/${ owner }  /${ repo }  .git`  } ,  logger : t . context . logger  } 
1177+     ) 
1178+   ) ; 
1179+   t . true ( gitlab . isDone ( ) ) ; 
1180+ } ) ; 
0 commit comments