@@ -25,6 +25,9 @@ import {Install} from '../../src/buildx/install';
2525
2626const tmpDir = fs . mkdtempSync ( path . join ( process . env . TEMP || os . tmpdir ( ) , 'buildx-install-' ) ) ;
2727
28+ // needs GitHub REST API to get releases JSON
29+ jest . unmock ( '@actions/github' ) ;
30+
2831afterEach ( function ( ) {
2932 rimraf . sync ( tmpDir ) ;
3033} ) ;
@@ -119,39 +122,64 @@ describe('getDownloadVersion', () => {
119122 expect ( version . key ) . toEqual ( 'official' ) ;
120123 expect ( version . version ) . toEqual ( 'latest' ) ;
121124 expect ( version . downloadURL ) . toEqual ( 'https://github.com/docker/buildx/releases/download/v%s/%s' ) ;
122- expect ( version . releasesURL ) . toEqual ( 'https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-releases.json' ) ;
125+ expect ( version . contentOpts ) . toEqual ( {
126+ owner : 'docker' ,
127+ repo : 'actions-toolkit' ,
128+ ref : 'main' ,
129+ path : '.github/buildx-releases.json'
130+ } ) ;
123131 } ) ;
124132
125133 it ( 'returns official v0.10.1 download version' , async ( ) => {
126134 const version = await Install . getDownloadVersion ( 'v0.10.1' ) ;
127135 expect ( version . key ) . toEqual ( 'official' ) ;
128136 expect ( version . version ) . toEqual ( 'v0.10.1' ) ;
129137 expect ( version . downloadURL ) . toEqual ( 'https://github.com/docker/buildx/releases/download/v%s/%s' ) ;
130- expect ( version . releasesURL ) . toEqual ( 'https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-releases.json' ) ;
138+ expect ( version . contentOpts ) . toEqual ( {
139+ owner : 'docker' ,
140+ repo : 'actions-toolkit' ,
141+ ref : 'main' ,
142+ path : '.github/buildx-releases.json'
143+ } ) ;
131144 } ) ;
132145
133146 it ( 'returns cloud latest download version' , async ( ) => {
134147 const version = await Install . getDownloadVersion ( 'cloud:latest' ) ;
135148 expect ( version . key ) . toEqual ( 'cloud' ) ;
136149 expect ( version . version ) . toEqual ( 'latest' ) ;
137150 expect ( version . downloadURL ) . toEqual ( 'https://github.com/docker/buildx-desktop/releases/download/v%s/%s' ) ;
138- expect ( version . releasesURL ) . toEqual ( 'https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-lab-releases.json' ) ;
151+ expect ( version . contentOpts ) . toEqual ( {
152+ owner : 'docker' ,
153+ repo : 'actions-toolkit' ,
154+ ref : 'main' ,
155+ path : '.github/buildx-lab-releases.json'
156+ } ) ;
139157 } ) ;
140158
141159 it ( 'returns cloud v0.11.2-desktop.2 download version' , async ( ) => {
142160 const version = await Install . getDownloadVersion ( 'cloud:v0.11.2-desktop.2' ) ;
143161 expect ( version . key ) . toEqual ( 'cloud' ) ;
144162 expect ( version . version ) . toEqual ( 'v0.11.2-desktop.2' ) ;
145163 expect ( version . downloadURL ) . toEqual ( 'https://github.com/docker/buildx-desktop/releases/download/v%s/%s' ) ;
146- expect ( version . releasesURL ) . toEqual ( 'https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-lab-releases.json' ) ;
164+ expect ( version . contentOpts ) . toEqual ( {
165+ owner : 'docker' ,
166+ repo : 'actions-toolkit' ,
167+ ref : 'main' ,
168+ path : '.github/buildx-lab-releases.json'
169+ } ) ;
147170 } ) ;
148171
149172 it ( 'returns cloud for lab version' , async ( ) => {
150173 const version = await Install . getDownloadVersion ( 'lab:latest' ) ;
151174 expect ( version . key ) . toEqual ( 'cloud' ) ;
152175 expect ( version . version ) . toEqual ( 'latest' ) ;
153176 expect ( version . downloadURL ) . toEqual ( 'https://github.com/docker/buildx-desktop/releases/download/v%s/%s' ) ;
154- expect ( version . releasesURL ) . toEqual ( 'https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-lab-releases.json' ) ;
177+ expect ( version . contentOpts ) . toEqual ( {
178+ owner : 'docker' ,
179+ repo : 'actions-toolkit' ,
180+ ref : 'main' ,
181+ path : '.github/buildx-lab-releases.json'
182+ } ) ;
155183 } ) ;
156184
157185 it ( 'unknown repo' , async ( ) => {
@@ -187,6 +215,6 @@ describe('getRelease', () => {
187215
188216 it ( 'unknown release' , async ( ) => {
189217 const version = await Install . getDownloadVersion ( 'foo' ) ;
190- await expect ( Install . getRelease ( version ) ) . rejects . toThrow ( new Error ( 'Cannot find Buildx release foo in https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx- releases.json ' ) ) ;
218+ await expect ( Install . getRelease ( version ) ) . rejects . toThrow ( new Error ( 'Cannot find Buildx release foo in releases JSON ' ) ) ;
191219 } ) ;
192220} ) ;
0 commit comments