@@ -16,6 +16,7 @@ const API = `https://gitlab.example.com/api/v4/projects/group%2Fapp/uploads/${SE
1616function fetchWith (
1717 token : string | null ,
1818 respond : ( url : string , authorization : string | undefined ) => Response ,
19+ url = UPLOAD ,
1920) {
2021 const requests : Array < [ string , string | undefined ] > = [ ] ;
2122 const invalidated : Array < string > = [ ] ;
@@ -36,7 +37,7 @@ function fetchWith(
3637 ) ;
3738 const status = Effect . gen ( function * ( ) {
3839 const fetchMedia = yield * GitLabMediaFetch . make ;
39- return ( yield * fetchMedia ( { url : UPLOAD , headers : { } } ) ) ?. status ;
40+ return ( yield * fetchMedia ( { url, headers : { } } ) ) ?. status ;
4041 } ) . pipe ( Effect . provide ( layer ) , Effect . scoped ) ;
4142 return { status, requests, invalidated } ;
4243}
@@ -65,11 +66,20 @@ describe("GitLabMediaFetch", () => {
6566 } ) ;
6667 } ) ;
6768
68- it . effect ( "loads the upload itself without a login, as a public project serves it" , ( ) => {
69- const { status, requests } = fetchWith ( null , ( ) => new Response ( null , { status : 200 } ) ) ;
69+ it . effect ( "loads a gitlab.com upload without a login, as a public project serves it" , ( ) => {
70+ const upload = `https://gitlab.com/group/app/uploads/${ SECRET } /shot.png` ;
71+ const { status, requests } = fetchWith ( null , ( ) => new Response ( null , { status : 200 } ) , upload ) ;
7072 return Effect . gen ( function * ( ) {
7173 expect ( yield * status ) . toBe ( 200 ) ;
72- expect ( requests ) . toEqual ( [ [ UPLOAD , undefined ] ] ) ;
74+ expect ( requests ) . toEqual ( [ [ upload , undefined ] ] ) ;
75+ } ) ;
76+ } ) ;
77+
78+ it . effect ( "asks no host that glab is not signed in to" , ( ) => {
79+ const { status, requests } = fetchWith ( null , ( ) => new Response ( null , { status : 200 } ) ) ;
80+ return Effect . gen ( function * ( ) {
81+ expect ( yield * status ) . toBeUndefined ( ) ;
82+ expect ( requests ) . toEqual ( [ ] ) ;
7383 } ) ;
7484 } ) ;
7585
0 commit comments