Skip to content

Commit a3f9d77

Browse files
committed
Add an assertCommonBuildInfo function
1 parent 5828779 commit a3f9d77

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

packages/compass-e2e-tests/smoke-test.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,7 @@ async function run() {
147147
writeBuildInfo(infoArgs);
148148
const buildInfo = await readJson(infoArgs.out);
149149

150-
if (!buildInfoIsCommon(buildInfo)) {
151-
throw new Error('buildInfo is missing');
152-
}
150+
assertCommonBuildInfo(buildInfo);
153151

154152
// filter the extensions given the platform (isWindows, isOSX, isUbuntu, isRHEL) and extension
155153
const { isWindows, isOSX, isRHEL, isUbuntu, extension } = context;
@@ -224,13 +222,16 @@ type PackageFilterConfig = Pick<
224222
const commonKeys = ['productName'];
225223
type CommonBuildInfo = Record<typeof commonKeys[number], string>;
226224

227-
function buildInfoIsCommon(buildInfo: any): buildInfo is CommonBuildInfo {
225+
function assertCommonBuildInfo(
226+
buildInfo: unknown
227+
): asserts buildInfo is CommonBuildInfo {
228+
assert(
229+
typeof buildInfo === 'object' && buildInfo !== null,
230+
'Expected buildInfo to be an object'
231+
);
228232
for (const key of commonKeys) {
229-
if (!buildInfo[key]) {
230-
return false;
231-
}
233+
assert(key in buildInfo, `Expected buildInfo to have '${key}'`);
232234
}
233-
return true;
234235
}
235236

236237
const windowsFilenameKeys = [

0 commit comments

Comments
 (0)