@@ -108,7 +108,7 @@ describe('download module test suite', () => {
108
108
} ) ;
109
109
} ) ;
110
110
111
- describe ( 'installCriDockerd' , ( ) => {
111
+ describe ( 'installCriDockerd with token ' , ( ) => {
112
112
let fs ;
113
113
let exec ;
114
114
beforeEach ( ( ) => {
@@ -117,12 +117,24 @@ describe('download module test suite', () => {
117
117
axios . mockImplementationOnce ( async ( ) => ( {
118
118
data : {
119
119
assets : [
120
+ {
121
+ name : 'cri-dockerd-0.2.3-3.el7.src.rpm' ,
122
+ browser_download_url : 'http://invalid'
123
+ } ,
124
+ {
125
+ name : 'cri-dockerd-0.2.3-3.el7.src.rpm' ,
126
+ browser_download_url : 'http://invalid'
127
+ } ,
120
128
{
121
129
name : 'cri-dockerd-v0.2.0-darwin-arm64.tar.gz' ,
122
130
browser_download_url : 'http://invalid'
123
131
} ,
124
132
{
125
- name : 'cri-dockerd-v0.2.0-linux-amd64.tar.gz' ,
133
+ name : 'cri-dockerd-0.2.3.arm64.tgz' ,
134
+ browser_download_url : 'http://invalid'
135
+ } ,
136
+ {
137
+ name : 'cri-dockerd-0.2.3.amd64.tgz' ,
126
138
browser_download_url : 'http://valid'
127
139
} ,
128
140
{
@@ -132,30 +144,48 @@ describe('download module test suite', () => {
132
144
]
133
145
}
134
146
} ) ) ;
147
+ tc . downloadTool . mockImplementationOnce ( async ( ) => 'cri-dockerd.tgz' ) ;
135
148
fs . readdirSync = jest . fn ( ( ) => [
136
149
{ isDirectory : ( ) => true , name : 'cri-dockerd' }
137
150
] ) ;
138
151
fs . readFileSync = jest . fn ( ( ) => '' ) ;
139
152
fs . writeFileSync = jest . fn ( ) ;
140
153
} ) ;
141
- test ( 'with token, should download and install valid Linux version' , async ( ) => {
142
- // Given
143
- tc . downloadTool . mockImplementationOnce ( async ( ) => 'cri-dockerd.tar.gz' ) ;
154
+ test ( 'should download Linux version' , async ( ) => {
144
155
// When
145
156
await download . installCriDockerd ( { githubToken : 'secret-token' } ) ;
146
157
// Then
147
158
expect ( axios ) . toHaveBeenCalledWith (
148
159
expect . objectContaining ( {
149
- url : 'https://api.github.com/repos/Mirantis/cri-dockerd/releases/tags/v0.2.0 ' ,
160
+ url : 'https://api.github.com/repos/Mirantis/cri-dockerd/releases/tags/v0.2.3 ' ,
150
161
headers : { Authorization : 'token secret-token' }
151
162
} )
152
163
) ;
153
164
expect ( tc . downloadTool ) . toHaveBeenCalledWith ( 'http://valid' ) ;
154
- expect ( tc . extractTar ) . toHaveBeenCalledWith (
155
- 'cri-dockerd.tar.gz' ,
156
- '/usr/local/bin'
165
+ } ) ;
166
+ test ( 'should install cri-dockerd binary' , async ( ) => {
167
+ // When
168
+ await download . installCriDockerd ( { githubToken : 'secret-token' } ) ;
169
+ // Then
170
+ expect ( tc . extractTar ) . toHaveBeenCalledWith ( 'cri-dockerd.tgz' ) ;
171
+ expect ( exec . logExecSync ) . toHaveBeenCalledWith (
172
+ expect . stringMatching (
173
+ / s u d o c p - a .+ \/ c r i - d o c k e r d \/ c r i - d o c k e r d \/ u s r \/ l o c a l \/ b i n \/ /
174
+ )
175
+ ) ;
176
+ expect ( exec . logExecSync ) . toHaveBeenCalledWith (
177
+ 'sudo ln -s /usr/local/bin/cri-dockerd /usr/bin/cri-dockerd'
178
+ ) ;
179
+ } ) ;
180
+ test ( 'should install cri-dockerd service' , async ( ) => {
181
+ // When
182
+ await download . installCriDockerd ( { githubToken : 'secret-token' } ) ;
183
+ // Then
184
+ expect ( exec . logExecSync ) . toHaveBeenCalledWith (
185
+ expect . stringMatching (
186
+ / s e d - i ' s \/ c r i - d o c k e r d - - \/ c r i - d o c k e r d - - n e t w o r k - p l u g i n = c n i - - \/ g ' /
187
+ )
157
188
) ;
158
- expect ( exec . logExecSync ) . toHaveBeenCalledTimes ( 4 ) ;
159
189
expect ( exec . logExecSync ) . toHaveBeenCalledWith (
160
190
expect . stringMatching (
161
191
/ s u d o c p - a .+ \/ p a c k a g i n g \/ s y s t e m d \/ \* \/ e t c \/ s y s t e m d \/ s y s t e m /
0 commit comments