Skip to content

Commit

Permalink
chore: fix gitHead snapshots again
Browse files Browse the repository at this point in the history
Somehow the last one didn't take?
  • Loading branch information
wraithgar committed Aug 26, 2021
1 parent e8b59ab commit eb1fbb7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
18 changes: 9 additions & 9 deletions tap-snapshots/test/lib/publish.js.test.cjs
Expand Up @@ -15,7 +15,7 @@ exports[`test/lib/publish.js TAP private workspaces colorless > should publish a
Array [
Object {
"_id": "@npmcli/b@1.0.0",
"gitHead": "1e8fd794b3375b083ab63224907213411099fa0e",
"gitHead": "{GITHEAD}",
"name": "@npmcli/b",
"readme": "ERROR: No README data found!",
"version": "1.0.0",
Expand All @@ -33,7 +33,7 @@ exports[`test/lib/publish.js TAP private workspaces with color > should publish
Array [
Object {
"_id": "@npmcli/b@1.0.0",
"gitHead": "1e8fd794b3375b083ab63224907213411099fa0e",
"gitHead": "{GITHEAD}",
"name": "@npmcli/b",
"readme": "ERROR: No README data found!",
"version": "1.0.0",
Expand Down Expand Up @@ -72,7 +72,7 @@ exports[`test/lib/publish.js TAP workspaces all workspaces > should publish all
Array [
Object {
"_id": "workspace-a@1.2.3-a",
"gitHead": "1e8fd794b3375b083ab63224907213411099fa0e",
"gitHead": "{GITHEAD}",
"name": "workspace-a",
"readme": "ERROR: No README data found!",
"repository": Object {
Expand All @@ -86,7 +86,7 @@ Array [
"bugs": Object {
"url": "https://github.com/npm/workspace-b/issues",
},
"gitHead": "1e8fd794b3375b083ab63224907213411099fa0e",
"gitHead": "{GITHEAD}",
"homepage": "https://github.com/npm/workspace-b#readme",
"name": "workspace-b",
"readme": "ERROR: No README data found!",
Expand All @@ -98,7 +98,7 @@ Array [
},
Object {
"_id": "workspace-n@1.2.3-n",
"gitHead": "1e8fd794b3375b083ab63224907213411099fa0e",
"gitHead": "{GITHEAD}",
"name": "workspace-n",
"readme": "ERROR: No README data found!",
"version": "1.2.3-n",
Expand Down Expand Up @@ -128,7 +128,7 @@ exports[`test/lib/publish.js TAP workspaces json > should publish all workspaces
Array [
Object {
"_id": "workspace-a@1.2.3-a",
"gitHead": "1e8fd794b3375b083ab63224907213411099fa0e",
"gitHead": "{GITHEAD}",
"name": "workspace-a",
"readme": "ERROR: No README data found!",
"repository": Object {
Expand All @@ -142,7 +142,7 @@ Array [
"bugs": Object {
"url": "https://github.com/npm/workspace-b/issues",
},
"gitHead": "1e8fd794b3375b083ab63224907213411099fa0e",
"gitHead": "{GITHEAD}",
"homepage": "https://github.com/npm/workspace-b#readme",
"name": "workspace-b",
"readme": "ERROR: No README data found!",
Expand All @@ -154,7 +154,7 @@ Array [
},
Object {
"_id": "workspace-n@1.2.3-n",
"gitHead": "1e8fd794b3375b083ab63224907213411099fa0e",
"gitHead": "{GITHEAD}",
"name": "workspace-n",
"readme": "ERROR: No README data found!",
"version": "1.2.3-n",
Expand All @@ -172,7 +172,7 @@ exports[`test/lib/publish.js TAP workspaces one workspace > should publish given
Array [
Object {
"_id": "workspace-a@1.2.3-a",
"gitHead": "1e8fd794b3375b083ab63224907213411099fa0e",
"gitHead": "{GITHEAD}",
"name": "workspace-a",
"readme": "ERROR: No README data found!",
"repository": Object {
Expand Down
18 changes: 13 additions & 5 deletions test/lib/publish.js
Expand Up @@ -9,6 +9,14 @@ const fs = require('fs')
const log = require('npmlog')
log.level = 'silent'

const cleanGithead = (result) => {
return result.map((r) => {
if (r.gitHead)
r.gitHead = '{GITHEAD}'

return r
})
}
const {definitions} = require('../../lib/utils/config')
const defaults = Object.entries(definitions).reduce((defaults, [key, def]) => {
defaults[key] = def.default
Expand Down Expand Up @@ -581,7 +589,7 @@ t.test('workspaces', (t) => {
log.level = 'info'
publish.execWorkspaces([], [], (err) => {
t.notOk(err)
t.matchSnapshot(publishes, 'should publish all workspaces')
t.matchSnapshot(cleanGithead(publishes), 'should publish all workspaces')
t.matchSnapshot(outputs, 'should output all publishes')
t.end()
})
Expand All @@ -591,7 +599,7 @@ t.test('workspaces', (t) => {
log.level = 'info'
publish.execWorkspaces([], ['workspace-a'], (err) => {
t.notOk(err)
t.matchSnapshot(publishes, 'should publish given workspace')
t.matchSnapshot(cleanGithead(publishes), 'should publish given workspace')
t.matchSnapshot(outputs, 'should output one publish')
t.end()
})
Expand All @@ -610,7 +618,7 @@ t.test('workspaces', (t) => {
npm.config.set('json', true)
publish.execWorkspaces([], [], (err) => {
t.notOk(err)
t.matchSnapshot(publishes, 'should publish all workspaces')
t.matchSnapshot(cleanGithead(publishes), 'should publish all workspaces')
t.matchSnapshot(outputs, 'should output all publishes as json')
t.end()
})
Expand Down Expand Up @@ -699,7 +707,7 @@ t.test('private workspaces', (t) => {
npm.color = true
publish.execWorkspaces([], [], (err) => {
t.notOk(err)
t.matchSnapshot(publishes, 'should publish all non-private workspaces')
t.matchSnapshot(cleanGithead(publishes), 'should publish all non-private workspaces')
t.matchSnapshot(outputs, 'should output all publishes')
npm.color = false
t.end()
Expand All @@ -726,7 +734,7 @@ t.test('private workspaces', (t) => {

publish.execWorkspaces([], [], (err) => {
t.notOk(err)
t.matchSnapshot(publishes, 'should publish all non-private workspaces')
t.matchSnapshot(cleanGithead(publishes), 'should publish all non-private workspaces')
t.matchSnapshot(outputs, 'should output all publishes')
t.end()
})
Expand Down

0 comments on commit eb1fbb7

Please sign in to comment.