test: improve tests that init a git repo

This commit is contained in:
Zoltan Kochan committed 2022-04-30 16:40:13 +03:00
1 parent 1ceb632b1c
commit d9d30d6fa2
7 files changed
+31 -32

No files matched your search

@@ -347,7 +347,7 @@ test('select changed packages', async () => {
}
const workspaceDir = tempy.directory()
await execa('git', ['init'], { cwd: workspaceDir })
await execa('git', ['init', '--initial-branch=main'], { cwd: workspaceDir })
await execa('git', ['config', 'user.email', 'x@y.z'], { cwd: workspaceDir })
await execa('git', ['config', 'user.name', 'xyz'], { cwd: workspaceDir })
await execa('git', ['commit', '--allow-empty', '--allow-empty-message', '-m', '', '--no-gpg-sign'], { cwd: workspaceDir })
@@ -1,14 +1,14 @@
lockfileVersion: 5.4
importers:
.:
dependencies:
'@zkochan/git-config': 0.1.0
is-positive: 1.0.0
specifiers:
'@zkochan/git-config': 0.1.0
is-positive: 1.0.0
lockfileVersion: 5.3
dependencies:
'@zkochan/git-config': 0.1.0
is-positive: 1.0.0
packages:
@@ -24,6 +24,5 @@ packages:
/is-positive/1.0.0:
resolution: {integrity: sha1-iACYVrZKLx632LsBeUGEJK4EUss=}
engines: {node: '>=0.10.0'}
dev: false
engines:
node: '>=0.10.0'
@@ -30,8 +30,7 @@ test('publish: fails git check if branch is not on master or main', async () =>
version: '0.0.0',
})
await execa('git', ['init'])
await execa('git', ['checkout', '-b', 'test'])
await execa('git', ['init', '--initial-branch=test'])
await execa('git', ['config', 'user.email', 'x@y.z'])
await execa('git', ['config', 'user.name', 'xyz'])
await execa('git', ['add', '*'])
@@ -87,7 +86,7 @@ test('publish: fails git check if branch is not clean', async () => {
version: '0.0.0',
})
await execa('git', ['init'])
await execa('git', ['init', '--initial-branch=main'])
await execa('git', ['config', 'user.email', 'x@y.z'])
await execa('git', ['config', 'user.name', 'xyz'])
await execa('git', ['add', '*'])
@@ -114,7 +113,7 @@ test('publish: fails git check if branch is not up-to-date', async () => {
version: '0.0.0',
})
await execa('git', ['init'])
await execa('git', ['init', '--initial-branch=main'])
await execa('git', ['config', 'user.email', 'x@y.z'])
await execa('git', ['config', 'user.name', 'xyz'])
await execa('git', ['init', '--bare'], { cwd: remote })
@@ -122,7 +121,7 @@ test('publish: fails git check if branch is not up-to-date', async () => {
await execa('git', ['commit', '-m', 'init', '--no-gpg-sign'])
await execa('git', ['commit', '--allow-empty', '--allow-empty-message', '-m', '', '--no-gpg-sign'])
await execa('git', ['remote', 'add', 'origin', remote])
await execa('git', ['push', '-u', 'origin', 'master'])
await execa('git', ['push', '-u', 'origin', 'main'])
await execa('git', ['reset', '--hard', 'HEAD~1'])
await expect(
@@ -693,8 +693,7 @@ test('publish: with specified publish branch name', async () => {
})
const branch = 'some-random-publish-branch'
await execa('git', ['init'])
await execa('git', ['checkout', '-b', branch])
await execa('git', ['init', '--initial-branch=branch'])
await execa('git', ['config', 'user.email', 'x@y.z'])
await execa('git', ['config', 'user.name', 'xyz'])
await execa('git', ['add', '*'])
+6 -6
View File
@@ -326,14 +326,14 @@ test('test-pattern is respected by the test script', async () => {
},
])
await execa('git', ['init'])
await execa('git', ['init', '--initial-branch=main'])
await execa('git', ['config', 'user.email', 'x@y.z'])
await execa('git', ['config', 'user.name', 'xyz'])
await execa('git', ['init', '--bare'], { cwd: remote })
await execa('git', ['add', '*'])
await execa('git', ['commit', '-m', 'init', '--no-gpg-sign'])
await execa('git', ['remote', 'add', 'origin', remote])
await execa('git', ['push', '-u', 'origin', 'master'])
await execa('git', ['push', '-u', 'origin', 'main'])
await fs.writeFile('project-2/file.js', '')
await fs.writeFile('project-4/different-pattern.js', '')
@@ -347,7 +347,7 @@ test('test-pattern is respected by the test script', async () => {
await execPnpm(['install'])
await execPnpm(['recursive', 'test', '--filter', '...[origin/master]'])
await execPnpm(['recursive', 'test', '--filter', '...[origin/main]'])
const { default: output } = await import(path.resolve('..', 'output.json'))
expect(output.sort()).toStrictEqual(['project-2', 'project-4'])
@@ -379,14 +379,14 @@ test('changed-files-ignore-pattern is respected', async () => {
},
])
await execa('git', ['init'])
await execa('git', ['init', '--initial-branch=main'])
await execa('git', ['config', 'user.email', 'x@y.z'])
await execa('git', ['config', 'user.name', 'xyz'])
await execa('git', ['init', '--bare'], { cwd: remote })
await execa('git', ['add', '*'])
await execa('git', ['commit', '-m', 'init', '--no-gpg-sign'])
await execa('git', ['remote', 'add', 'origin', remote])
await execa('git', ['push', '-u', 'origin', 'master'])
await execa('git', ['push', '-u', 'origin', 'main'])
const npmrcLines = []
await fs.writeFile('project-2-change-is-never-ignored/index.js', '')
@@ -427,7 +427,7 @@ test('changed-files-ignore-pattern is respected', async () => {
const result = await execPnpmSync(
[
'--filter',
'[origin/master]',
'[origin/main]',
opts?.overrideChangedFilesIgnorePatternWithNoPattern
? '--changed-files-ignore-pattern='
: '',
@@ -1,12 +1,14 @@
dependencies:
is-positive: 3.1.0
lockfileVersion: 5.2
packages:
/is-positive/3.1.0:
dev: false
engines:
node: '>=0.10.0'
resolution:
integrity: sha1-hX21hKG6XRyymAUn/DtsQ103sP0=
lockfileVersion: 5.4
specifiers:
is-positive: 3.1.0
dependencies:
is-positive: 3.1.0
packages:
/is-positive/3.1.0:
resolution: {integrity: sha1-hX21hKG6XRyymAUn/DtsQ103sP0=}
engines: {node: '>=0.10.0'}
dev: false
+1 -1
View File
@@ -29,7 +29,7 @@
"scripts": {
"lint": "tslint -c ../../tslint.json --project .",
"compile": "rimraf tsconfig.tsbuildinfo lib && tsc --build",
"test": "pnpm run tsc"
"test": "pnpm run compile"
},
"dependencies": {
"@pnpm/prepare": "workspace:*",