Skip to content

Commit

Permalink
[7.x] [src/dev/build] remove node-version from snapshots (#75303) (#7…
Browse files Browse the repository at this point in the history
…5358)

Co-authored-by: spalger <[email protected]>

Co-authored-by: spalger <[email protected]>
  • Loading branch information
Spencer and spalger authored Aug 18, 2020
1 parent f23b196 commit 6c4b5d3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
29 changes: 21 additions & 8 deletions src/dev/build/tasks/nodejs/extract_node_builds_task.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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('<node version>')
)
);

async function setup() {
const config = await Config.create({
isRelease: true,
Expand Down Expand Up @@ -74,31 +87,31 @@ it('runs expected fs operations', async () => {
Object {
"copy": Array [
Array [
<absolute path>/.node_binaries/10.21.0/node.exe,
<absolute path>/.node_binaries/10.21.0/win32-x64/node.exe,
<absolute path>/.node_binaries/<node version>/node.exe,
<absolute path>/.node_binaries/<node version>/win32-x64/node.exe,
Object {
"clone": true,
},
],
],
"untar": Array [
Array [
<absolute path>/.node_binaries/10.21.0/node-v10.21.0-linux-x64.tar.gz,
<absolute path>/.node_binaries/10.21.0/linux-x64,
<absolute path>/.node_binaries/<node version>/node-v<node version>-linux-x64.tar.gz,
<absolute path>/.node_binaries/<node version>/linux-x64,
Object {
"strip": 1,
},
],
Array [
<absolute path>/.node_binaries/10.21.0/node-v10.21.0-linux-arm64.tar.gz,
<absolute path>/.node_binaries/10.21.0/linux-arm64,
<absolute path>/.node_binaries/<node version>/node-v<node version>-linux-arm64.tar.gz,
<absolute path>/.node_binaries/<node version>/linux-arm64,
Object {
"strip": 1,
},
],
Array [
<absolute path>/.node_binaries/10.21.0/node-v10.21.0-darwin-x64.tar.gz,
<absolute path>/.node_binaries/10.21.0/darwin-x64,
<absolute path>/.node_binaries/<node version>/node-v<node version>-darwin-x64.tar.gz,
<absolute path>/.node_binaries/<node version>/darwin-x64,
Object {
"strip": 1,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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('<node version>')
)
);

async function setup(actualShaSums?: Record<string, string>) {
const config = await Config.create({
isRelease: true,
Expand Down Expand Up @@ -87,7 +100,7 @@ it('checks shasums for each downloaded node build', async () => {
[MockFunction] {
"calls": Array [
Array [
"10.21.0",
"<node version>",
],
],
"results": Array [
Expand Down

0 comments on commit 6c4b5d3

Please sign in to comment.