@@ -20,33 +20,34 @@ describe("deleteCache", () => {
2020 ok : true ,
2121 status : 200 ,
2222 statusText : "OK" ,
23- json : ( ) => Promise . resolve ( { deleted : 1 } ) ,
23+ json : ( ) => Promise . resolve ( { count : 1 } ) ,
2424 } as Response ) ;
2525 } ) ;
2626
2727 const defaultParams = {
28- baseUrl : "https://api.blacksmith.sh/cache" ,
29- repoName : "test-repo" ,
28+ baseUrl : "http://baseurl/" ,
3029 cacheToken : "test-token" ,
31- region : "eu-central" ,
3230 } ;
3331
34- it ( "should send DELETE request for a specific cache key" , async ( ) => {
32+ it ( "should send request to delete a specific cache key" , async ( ) => {
3533 await deleteCache ( {
3634 cacheKey : "npm-cache" ,
3735 ...defaultParams ,
3836 } ) ;
3937
4038 expect ( mockedFetch ) . toHaveBeenCalledWith (
41- "https ://api.blacksmith.sh/cache/caches/npm-cache " ,
39+ "http ://baseurl/twirp/github.actions.results. api.v1.CacheService/DeleteCacheEntry " ,
4240 {
43- method : "DELETE " ,
41+ method : "POST " ,
4442 headers : {
43+ "Content-Type" : "application/json" ,
4544 Accept : "application/json; version=6.0-preview.1" ,
46- "X-GitHub-Repo-Name" : "test-repo" ,
4745 Authorization : "Bearer test-token" ,
48- "X-Cache-Region" : "eu-central" ,
4946 } ,
47+ body : JSON . stringify ( {
48+ key : "npm-cache" ,
49+ prefix : false ,
50+ } ) ,
5051 }
5152 ) ;
5253 expect ( mockedInfo ) . toHaveBeenCalledWith (
@@ -55,23 +56,27 @@ describe("deleteCache", () => {
5556 expect ( mockedInfo ) . toHaveBeenCalledWith ( "Deleted 1 cache entries" ) ;
5657 } ) ;
5758
58- it ( "should send DELETE request for a specific cache version" , async ( ) => {
59+ it ( "should send request to delete a specific cache version" , async ( ) => {
5960 await deleteCache ( {
6061 cacheKey : "npm-cache" ,
6162 cacheVersion : "v1.0" ,
6263 ...defaultParams ,
6364 } ) ;
6465
6566 expect ( mockedFetch ) . toHaveBeenCalledWith (
66- "https ://api.blacksmith.sh/cache/caches/npm-cache/ v1.0 " ,
67+ "http ://baseurl/twirp/github.actions.results.api. v1.CacheService/DeleteCacheEntry " ,
6768 {
68- method : "DELETE " ,
69+ method : "POST " ,
6970 headers : {
71+ "Content-Type" : "application/json" ,
7072 Accept : "application/json; version=6.0-preview.1" ,
71- "X-GitHub-Repo-Name" : "test-repo" ,
7273 Authorization : "Bearer test-token" ,
73- "X-Cache-Region" : "eu-central" ,
7474 } ,
75+ body : JSON . stringify ( {
76+ key : "npm-cache" ,
77+ version : "v1.0" ,
78+ prefix : false ,
79+ } ) ,
7580 }
7681 ) ;
7782 expect ( mockedInfo ) . toHaveBeenCalledWith (
@@ -80,12 +85,12 @@ describe("deleteCache", () => {
8085 expect ( mockedInfo ) . toHaveBeenCalledWith ( "Deleted 1 cache entries" ) ;
8186 } ) ;
8287
83- it ( "should send DELETE request with prefix parameter" , async ( ) => {
88+ it ( "should send request with prefix parameter" , async ( ) => {
8489 mockedFetch . mockResolvedValue ( {
8590 ok : true ,
8691 status : 200 ,
8792 statusText : "OK" ,
88- json : ( ) => Promise . resolve ( { deleted : 5 } ) ,
93+ json : ( ) => Promise . resolve ( { count : 5 } ) ,
8994 } as Response ) ;
9095
9196 await deleteCache ( {
@@ -95,15 +100,18 @@ describe("deleteCache", () => {
95100 } ) ;
96101
97102 expect ( mockedFetch ) . toHaveBeenCalledWith (
98- "https ://api.blacksmith.sh/cache/caches/npm-?prefix " ,
103+ "http ://baseurl/twirp/github.actions.results. api.v1.CacheService/DeleteCacheEntry " ,
99104 {
100- method : "DELETE " ,
105+ method : "POST " ,
101106 headers : {
107+ "Content-Type" : "application/json" ,
102108 Accept : "application/json; version=6.0-preview.1" ,
103- "X-GitHub-Repo-Name" : "test-repo" ,
104109 Authorization : "Bearer test-token" ,
105- "X-Cache-Region" : "eu-central" ,
106110 } ,
111+ body : JSON . stringify ( {
112+ key : "npm-" ,
113+ prefix : true ,
114+ } ) ,
107115 }
108116 ) ;
109117 expect ( mockedInfo ) . toHaveBeenCalledWith (
@@ -112,12 +120,12 @@ describe("deleteCache", () => {
112120 expect ( mockedInfo ) . toHaveBeenCalledWith ( "Deleted 5 cache entries" ) ;
113121 } ) ;
114122
115- it ( "should send DELETE request with empty key and prefix parameter" , async ( ) => {
123+ it ( "should send request with empty key and prefix parameter" , async ( ) => {
116124 mockedFetch . mockResolvedValue ( {
117125 ok : true ,
118126 status : 200 ,
119127 statusText : "OK" ,
120- json : ( ) => Promise . resolve ( { deleted : 10 } ) ,
128+ json : ( ) => Promise . resolve ( { count : 10 } ) ,
121129 } as Response ) ;
122130
123131 await deleteCache ( {
@@ -127,15 +135,18 @@ describe("deleteCache", () => {
127135 } ) ;
128136
129137 expect ( mockedFetch ) . toHaveBeenCalledWith (
130- "https ://api.blacksmith.sh/cache/caches/?prefix " ,
138+ "http ://baseurl/twirp/github.actions.results. api.v1.CacheService/DeleteCacheEntry " ,
131139 {
132- method : "DELETE " ,
140+ method : "POST " ,
133141 headers : {
142+ "Content-Type" : "application/json" ,
134143 Accept : "application/json; version=6.0-preview.1" ,
135- "X-GitHub-Repo-Name" : "test-repo" ,
136144 Authorization : "Bearer test-token" ,
137- "X-Cache-Region" : "eu-central" ,
138145 } ,
146+ body : JSON . stringify ( {
147+ key : "" ,
148+ prefix : true ,
149+ } ) ,
139150 }
140151 ) ;
141152 expect ( mockedInfo ) . toHaveBeenCalledWith (
0 commit comments