1
1
import { expect } from 'chai' ;
2
- import fs from 'fs-extra ' ;
2
+ import { promises as fs } from 'fs' ;
3
3
import nock from 'nock' ;
4
4
import fetch from 'node-fetch' ;
5
5
import path from 'path' ;
6
6
import sinon from 'sinon' ;
7
7
import { URL } from 'url' ;
8
- import { Barque , LATEST_CURATOR } from './barque' ;
8
+ import { Barque , LATEST_CURATOR , getReposAndArch } from './barque' ;
9
9
import { ALL_BUILD_VARIANTS , Config } from './config' ;
10
10
11
11
describe ( 'Barque' , ( ) => {
@@ -55,16 +55,19 @@ describe('Barque', () => {
55
55
variant : 'debian-x64' ,
56
56
url : 'https://s3.amazonaws.com/mciuploads/mongosh/5ed7ee5d8683818eb28d9d3b5c65837cde4a08f5/mongodb-mongosh_0.1.0_amd64.deb' ,
57
57
publishedUrls : [
58
- `${ Barque . PPA_REPO_BASE_URL } /apt/debian/dists/buster/mongodb-org/4.4/main/binary-amd64/mongodb-mongosh_0.1.0_amd64.deb` ,
59
58
`${ Barque . PPA_REPO_BASE_URL } /apt/ubuntu/dists/bionic/mongodb-org/4.4/multiverse/binary-amd64/mongodb-mongosh_0.1.0_amd64.deb` ,
60
59
`${ Barque . PPA_REPO_BASE_URL } /apt/ubuntu/dists/focal/mongodb-org/4.4/multiverse/binary-amd64/mongodb-mongosh_0.1.0_amd64.deb` ,
60
+ `${ Barque . PPA_REPO_BASE_URL } /apt/debian/dists/buster/mongodb-org/4.4/main/binary-amd64/mongodb-mongosh_0.1.0_amd64.deb` ,
61
+ `${ Barque . PPA_REPO_BASE_URL } /apt/debian/dists/stretch/mongodb-org/4.4/main/binary-amd64/mongodb-mongosh_0.1.0_amd64.deb`
61
62
]
62
63
} ,
63
64
{
64
65
variant : 'rhel-x64' ,
65
66
url : 'https://s3.amazonaws.com/mciuploads/mongosh/5ed7ee5d8683818eb28d9d3b5c65837cde4a08f5/mongodb-mongosh-0.1.0.el7.x86_64.rpm' ,
66
67
publishedUrls : [
68
+ `${ Barque . PPA_REPO_BASE_URL } /yum/redhat/7/mongodb-org/4.4/x86_64/RPMS/mongodb-mongosh-0.1.0.el7.x86_64.rpm` ,
67
69
`${ Barque . PPA_REPO_BASE_URL } /yum/redhat/8/mongodb-org/4.4/x86_64/RPMS/mongodb-mongosh-0.1.0.el7.x86_64.rpm` ,
70
+ `${ Barque . PPA_REPO_BASE_URL } /yum/amazon/2/mongodb-org/4.4/x86_64/RPMS/mongodb-mongosh-0.1.0.el7.x86_64.rpm` ,
68
71
]
69
72
}
70
73
] as const ) . forEach ( ( { variant, url, publishedUrls } ) => {
@@ -93,7 +96,7 @@ describe('Barque', () => {
93
96
try {
94
97
await barque . releaseToBarque ( 'debian-x64' , debUrl ) ;
95
98
} catch ( error ) {
96
- expect ( error . message ) . to . include ( 'Curator is unable to upload to barque' ) ;
99
+ expect ( error . message ) . to . include ( 'Curator is unable to upload https://s3.amazonaws.com/mciuploads/mongosh/5ed7ee5d8683818eb28d9d3b5c65837cde4a08f5/mongodb-mongosh_0.1.0_amd64.deb,ubuntu1804,amd64 to barque' ) ;
97
100
expect ( barque . createCuratorDir ) . to . have . been . called ;
98
101
expect ( barque . extractLatestCurator ) . to . have . been . called ;
99
102
expect ( barque . execCurator ) . to . have . been . called ;
@@ -115,56 +118,14 @@ describe('Barque', () => {
115
118
} ) ;
116
119
} ) ;
117
120
118
- describe ( 'getTargetDistro' , ( ) => {
119
- it ( 'determines distro for debian build variant' , async ( ) => {
120
- const distro = barque . getTargetDistros ( 'debian-x64' ) ;
121
- expect ( distro ) . to . deep . equal ( [ 'debian10' , 'ubuntu1804' , 'ubuntu2004' ] ) ;
122
- } ) ;
123
-
124
- it ( 'determines distro for redhat build variant' , async ( ) => {
125
- const distro = barque . getTargetDistros ( 'rhel-x64' ) ;
126
- expect ( distro ) . to . deep . equal ( [ 'rhel80' ] ) ;
127
- } ) ;
128
-
129
- ALL_BUILD_VARIANTS
130
- . filter ( v => v !== 'debian-x64' && v !== 'rhel-x64' )
131
- . forEach ( variant => {
132
- it ( `throws an error for ${ variant } ` , async ( ) => {
133
- try {
134
- barque . getTargetDistros ( variant ) ;
135
- } catch ( e ) {
136
- expect ( e . message ) . to . include ( variant ) ;
137
- return ;
138
- }
139
- expect . fail ( 'Expected error' ) ;
140
- } ) ;
141
- } ) ;
142
- } ) ;
143
-
144
- describe ( 'getTargetArchitecture' , ( ) => {
145
- it ( 'determines arch for debian' , async ( ) => {
146
- const distro = barque . getTargetArchitecture ( 'debian-x64' ) ;
147
- expect ( distro ) . to . be . equal ( 'amd64' ) ;
148
- } ) ;
149
-
150
- it ( 'determines arch for redhat' , async ( ) => {
151
- const distro = barque . getTargetArchitecture ( 'rhel-x64' ) ;
152
- expect ( distro ) . to . be . equal ( 'x86_64' ) ;
153
- } ) ;
154
-
155
- ALL_BUILD_VARIANTS
156
- . filter ( v => v !== 'debian-x64' && v !== 'rhel-x64' )
157
- . forEach ( variant => {
158
- it ( `throws an error for ${ variant } ` , async ( ) => {
159
- try {
160
- barque . getTargetArchitecture ( variant ) ;
161
- } catch ( e ) {
162
- expect ( e . message ) . to . include ( variant ) ;
163
- return ;
164
- }
165
- expect . fail ( 'Expected error' ) ;
166
- } ) ;
121
+ describe ( 'getReposAndArch' , ( ) => {
122
+ for ( const variant of ALL_BUILD_VARIANTS ) {
123
+ it ( `returns results for ${ variant } ` , ( ) => {
124
+ const result = getReposAndArch ( variant ) ;
125
+ expect ( result . ppas ) . to . be . an ( 'array' ) ;
126
+ expect ( result . arch ) . to . be . a ( 'string' ) ;
167
127
} ) ;
128
+ }
168
129
} ) ;
169
130
170
131
describe ( 'createCuratorDir' , ( ) => {
0 commit comments