@@ -833,3 +833,68 @@ test.serial('Does not throw an error for option without validator', async (t) =>
833
833
) ;
834
834
t . true ( gitlab . isDone ( ) ) ;
835
835
} ) ;
836
+
837
+ test . serial (
838
+ 'Won\'t throw SemanticReleaseError if "assets" option is an Array of objects with url field but missing the "path" property' ,
839
+ async ( t ) => {
840
+ const owner = 'test_user' ;
841
+ const repo = 'test_repo' ;
842
+ const env = { GITLAB_TOKEN : 'gitlab_token' } ;
843
+ const assets = [ { url : 'https://gitlab.com/gitlab-org/gitlab/-/blob/master/README.md' } ] ;
844
+ const gitlab = authenticate ( env )
845
+ . get ( `/projects/${ owner } %2F${ repo } ` )
846
+ . reply ( 200 , { permissions : { project_access : { access_level : 40 } } } ) ;
847
+
848
+ await t . notThrowsAsync (
849
+ verify (
850
+ { assets} ,
851
+ { env, options : { repositoryUrl : `https://gitlab.com/${ owner } /${ repo } .git` } , logger : t . context . logger }
852
+ )
853
+ ) ;
854
+ t . true ( gitlab . isDone ( ) ) ;
855
+ }
856
+ ) ;
857
+
858
+ test . serial (
859
+ 'Won\'t throw SemanticReleaseError if "assets" option is an Array of objects with path field but missing the "url" property' ,
860
+ async ( t ) => {
861
+ const owner = 'test_user' ;
862
+ const repo = 'test_repo' ;
863
+ const env = { GITLAB_TOKEN : 'gitlab_token' } ;
864
+ const assets = [ { path : 'README.md' } ] ;
865
+ const gitlab = authenticate ( env )
866
+ . get ( `/projects/${ owner } %2F${ repo } ` )
867
+ . reply ( 200 , { permissions : { project_access : { access_level : 40 } } } ) ;
868
+
869
+ await t . notThrowsAsync (
870
+ verify (
871
+ { assets} ,
872
+ { env, options : { repositoryUrl : `https://gitlab.com/${ owner } /${ repo } .git` } , logger : t . context . logger }
873
+ )
874
+ ) ;
875
+ t . true ( gitlab . isDone ( ) ) ;
876
+ }
877
+ ) ;
878
+
879
+ test . serial (
880
+ 'Throw SemanticReleaseError if "assets" option is an Array of objects without url nor path property' ,
881
+ async ( t ) => {
882
+ const owner = 'test_user' ;
883
+ const repo = 'test_repo' ;
884
+ const env = { GITLAB_TOKEN : 'gitlab_token' } ;
885
+ const assets = [ { name : 'README.md' } ] ;
886
+ const gitlab = authenticate ( env )
887
+ . get ( `/projects/${ owner } %2F${ repo } ` )
888
+ . reply ( 200 , { permissions : { project_access : { access_level : 40 } } } ) ;
889
+
890
+ const [ error ] = await t . throwsAsync (
891
+ verify (
892
+ { assets} ,
893
+ { env, options : { repositoryUrl : `https://gitlab.com/${ owner } /${ repo } .git` } , logger : t . context . logger }
894
+ )
895
+ ) ;
896
+ t . is ( error . name , 'SemanticReleaseError' ) ;
897
+ t . is ( error . code , 'EINVALIDASSETS' ) ;
898
+ t . true ( gitlab . isDone ( ) ) ;
899
+ }
900
+ ) ;
0 commit comments