From 3b85b41565ecc3c40375237a47c805f5fb58c264 Mon Sep 17 00:00:00 2001 From: spalger Date: Tue, 18 Aug 2020 08:18:31 -0700 Subject: [PATCH] [src/dev/build] remove node-version from snapshots --- .../nodejs/extract_node_builds_task.test.ts | 29 ++++++++++++++----- .../verify_existing_node_builds_task.test.ts | 15 +++++++++- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/dev/build/tasks/nodejs/extract_node_builds_task.test.ts b/src/dev/build/tasks/nodejs/extract_node_builds_task.test.ts index f1700ef7b578c..a5b9e01714f38 100644 --- a/src/dev/build/tasks/nodejs/extract_node_builds_task.test.ts +++ b/src/dev/build/tasks/nodejs/extract_node_builds_task.test.ts @@ -17,10 +17,15 @@ * under the License. */ +import { readFileSync } from 'fs'; +import Path from 'path'; + import { ToolingLog, ToolingLogCollectingWriter, createAbsolutePathSerializer, + createRecursiveSerializer, + REPO_ROOT, } from '@kbn/dev-utils'; import { Config } from '../../lib'; @@ -37,6 +42,14 @@ log.setWriters([testWriter]); expect.addSnapshotSerializer(createAbsolutePathSerializer()); +const nodeVersion = readFileSync(Path.resolve(REPO_ROOT, '.node-version'), 'utf8').trim(); +expect.addSnapshotSerializer( + createRecursiveSerializer( + (s) => typeof s === 'string' && s.includes(nodeVersion), + (s) => s.split(nodeVersion).join('') + ) +); + async function setup() { const config = await Config.create({ isRelease: true, @@ -74,8 +87,8 @@ it('runs expected fs operations', async () => { Object { "copy": Array [ Array [ - /.node_binaries/10.21.0/node.exe, - /.node_binaries/10.21.0/win32-x64/node.exe, + /.node_binaries//node.exe, + /.node_binaries//win32-x64/node.exe, Object { "clone": true, }, @@ -83,22 +96,22 @@ it('runs expected fs operations', async () => { ], "untar": Array [ Array [ - /.node_binaries/10.21.0/node-v10.21.0-linux-x64.tar.gz, - /.node_binaries/10.21.0/linux-x64, + /.node_binaries//node-v-linux-x64.tar.gz, + /.node_binaries//linux-x64, Object { "strip": 1, }, ], Array [ - /.node_binaries/10.21.0/node-v10.21.0-linux-arm64.tar.gz, - /.node_binaries/10.21.0/linux-arm64, + /.node_binaries//node-v-linux-arm64.tar.gz, + /.node_binaries//linux-arm64, Object { "strip": 1, }, ], Array [ - /.node_binaries/10.21.0/node-v10.21.0-darwin-x64.tar.gz, - /.node_binaries/10.21.0/darwin-x64, + /.node_binaries//node-v-darwin-x64.tar.gz, + /.node_binaries//darwin-x64, Object { "strip": 1, }, diff --git a/src/dev/build/tasks/nodejs/verify_existing_node_builds_task.test.ts b/src/dev/build/tasks/nodejs/verify_existing_node_builds_task.test.ts index 19416963d5edd..1a850890a33fe 100644 --- a/src/dev/build/tasks/nodejs/verify_existing_node_builds_task.test.ts +++ b/src/dev/build/tasks/nodejs/verify_existing_node_builds_task.test.ts @@ -17,10 +17,15 @@ * under the License. */ +import Path from 'path'; +import Fs from 'fs'; + import { ToolingLog, ToolingLogCollectingWriter, createAnyInstanceSerializer, + createRecursiveSerializer, + REPO_ROOT, } from '@kbn/dev-utils'; import { Config, Platform } from '../../lib'; @@ -41,6 +46,14 @@ log.setWriters([testWriter]); expect.addSnapshotSerializer(createAnyInstanceSerializer(Config)); +const nodeVersion = Fs.readFileSync(Path.resolve(REPO_ROOT, '.node-version'), 'utf8').trim(); +expect.addSnapshotSerializer( + createRecursiveSerializer( + (s) => typeof s === 'string' && s.includes(nodeVersion), + (s) => s.split(nodeVersion).join('') + ) +); + async function setup(actualShaSums?: Record) { const config = await Config.create({ isRelease: true, @@ -87,7 +100,7 @@ it('checks shasums for each downloaded node build', async () => { [MockFunction] { "calls": Array [ Array [ - "10.21.0", + "", ], ], "results": Array [