-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dependency: update dependency simple-git to v3.25.0 (#30076)
* empty commit * fix(deps): update dependency simple-git to v3.25.0 * cli entry * yarnlock * mock out simple-git for failing unit tests * fix yarn lock merge * changelog --------- Co-authored-by: Jennifer Shehane <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Cacie Prins <[email protected]>
- Loading branch information
1 parent
f98810c
commit 619a9ab
Showing
5 changed files
with
199 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
178 changes: 178 additions & 0 deletions
178
packages/data-context/test/unit/sources/GitDataSource_unit.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
import { expect, use } from 'chai' | ||
import sinonChai from 'sinon-chai' | ||
import sinon from 'sinon' | ||
import proxyquire from 'proxyquire' | ||
import pDefer, { DeferredPromise } from 'p-defer' | ||
|
||
import { SimpleGit } from 'simple-git' | ||
import type { GitDataSource, GitDataSourceConfig } from '../../../src/sources/GitDataSource' | ||
import Chokidar from 'chokidar' | ||
|
||
use(sinonChai) | ||
|
||
type P<F extends keyof SimpleGit> = Parameters<SimpleGit[F]> | ||
type R<F extends keyof SimpleGit> = ReturnType<SimpleGit[F]> | ||
|
||
interface GitDataSourceConstructor { | ||
new (config: GitDataSourceConfig): GitDataSource | ||
} | ||
|
||
type GDSImport = { | ||
GitDataSource: GitDataSourceConstructor | ||
} | ||
|
||
describe('GitDataSource', () => { | ||
let stubbedSimpleGit: { | ||
// Parameters<> only gets the last overload defined, which is | ||
// supposed to be the most permissive. However, SimpleGit defines | ||
// overloads in the opposite order, and we need the one that takes | ||
// a string. | ||
revparse: sinon.SinonStub<[option: string], R<'revparse'>> | ||
branch: sinon.SinonStub<P<'branch'>, R<'branch'>> | ||
status: sinon.SinonStub<P<'status'>, R<'status'>> | ||
log: sinon.SinonStub<P<'log'>, R<'log'>> | ||
} | ||
let stubbedWatchInstance: sinon.SinonStubbedInstance<Chokidar.FSWatcher> | ||
|
||
let gitDataSourceImport: GDSImport | ||
let fakeTimers: sinon.SinonFakeTimers | ||
|
||
beforeEach(() => { | ||
fakeTimers = sinon.useFakeTimers() | ||
stubbedSimpleGit = { | ||
revparse: sinon.stub<[option: string], R<'revparse'>>(), | ||
branch: sinon.stub<P<'branch'>, R<'branch'>>(), | ||
status: sinon.stub<P<'status'>, R<'status'>>(), | ||
log: sinon.stub<P<'log'>, R<'log'>>(), | ||
} | ||
|
||
stubbedWatchInstance = sinon.createStubInstance(Chokidar.FSWatcher) | ||
sinon.stub(Chokidar, 'watch').returns(stubbedWatchInstance) | ||
|
||
gitDataSourceImport = proxyquire.noCallThru()('../../../src/sources/GitDataSource', { | ||
'simple-git' () { | ||
return stubbedSimpleGit | ||
}, | ||
}) | ||
}) | ||
|
||
afterEach(() => { | ||
sinon.restore() | ||
fakeTimers.restore() | ||
}) | ||
|
||
describe('Unit', () => { | ||
describe('in open mode', () => { | ||
let gds: GitDataSource | ||
let projectRoot: string | ||
let branchName: string | ||
let onBranchChange: sinon.SinonStub<[branch: string | null], void> | ||
let onGitInfoChange: sinon.SinonStub<[specPath: string[]], void> | ||
let onError: sinon.SinonStub<[err: any], void> | ||
let onGitLogChange: sinon.SinonStub<[shas: string[]], void> | ||
const firstHashes = [ | ||
{ hash: 'abc' }, | ||
] | ||
const firstHashesReturnValue = ['abc'] | ||
const secondHashes = [...firstHashes, { hash: 'efg' }] | ||
const secondHashesReturnValue = [...firstHashesReturnValue, 'efg'] | ||
let firstGitLogCall: DeferredPromise<void> | ||
let secondGitLogCall: DeferredPromise<void> | ||
|
||
beforeEach(async () => { | ||
firstGitLogCall = pDefer() | ||
secondGitLogCall = pDefer() | ||
branchName = 'main' | ||
onBranchChange = sinon.stub() | ||
onGitInfoChange = sinon.stub() | ||
onError = sinon.stub() | ||
onGitLogChange = sinon.stub() | ||
|
||
projectRoot = '/root' | ||
|
||
// @ts-ignore | ||
stubbedSimpleGit.log.onFirstCall() | ||
// @ts-expect-error | ||
.callsFake(() => { | ||
firstGitLogCall.resolve() | ||
|
||
return { all: firstHashes } | ||
}) | ||
.onSecondCall() | ||
// @ts-expect-error | ||
.callsFake(() => { | ||
secondGitLogCall.resolve() | ||
|
||
return { all: secondHashes } | ||
}) | ||
|
||
// #verifyGitRepo | ||
|
||
// constructor verifies the repo in open mode via #refreshAllGitData, but does not wait for it :womp: | ||
const revparseP = pDefer<void>() | ||
|
||
// SimpleGit returns a chainable, but we only care about the promise | ||
// @ts-expect-error | ||
stubbedSimpleGit.revparse.callsFake(() => { | ||
revparseP.resolve() | ||
|
||
return Promise.resolve(projectRoot) | ||
}) | ||
|
||
// wait for revparse to be called, so we can be assured that GitDataSource has initialized | ||
// up to this point | ||
|
||
// #loadAndWatchCurrentBranch | ||
|
||
// next in initialization, it loads the current branch | ||
const branchP = pDefer<void>() | ||
|
||
// again, ignoring type warning re: chaining | ||
// @ts-expect-error | ||
stubbedSimpleGit.branch.callsFake(() => { | ||
branchP.resolve() | ||
|
||
return Promise.resolve({ current: branchName }) | ||
}) | ||
|
||
const onBranchChangeP = pDefer<void>() | ||
|
||
onBranchChange.callsFake(() => onBranchChangeP.resolve()) | ||
|
||
gds = new gitDataSourceImport.GitDataSource({ | ||
isRunMode: false, | ||
projectRoot, | ||
onBranchChange, | ||
onGitInfoChange, | ||
onError, | ||
onGitLogChange, | ||
}) | ||
|
||
await revparseP.promise | ||
await branchP.promise | ||
await onBranchChangeP.promise | ||
expect(onBranchChange).to.be.calledWith(branchName) | ||
}) | ||
|
||
describe('.get currentHashes', () => { | ||
describe('after first load', () => { | ||
beforeEach(async () => { | ||
await firstGitLogCall.promise | ||
}) | ||
|
||
it('returns the current hashes', () => { | ||
expect(gds.currentHashes).to.have.same.members(firstHashesReturnValue) | ||
}) | ||
}) | ||
|
||
describe('after sixty seconds, when there are additional hashes', () => { | ||
it('returns the current hashes', async () => { | ||
await fakeTimers.tickAsync(60001) | ||
await secondGitLogCall.promise | ||
expect(gds.currentHashes).to.have.same.members(secondHashesReturnValue) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13306,10 +13306,10 @@ [email protected]: | |
dependencies: | ||
ms "^2.1.1" | ||
|
||
debug@4, debug@4.3.4, debug@^4.0.0, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4, debug@~4.3.1: | ||
version "4.3.4" | ||
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" | ||
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== | ||
debug@4, debug@^4.0.0, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4, debug@^4.3.5, debug@~4.3.1: | ||
version "4.3.6" | ||
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.6.tgz#2ab2c38fbaffebf8aa95fdfe6d88438c7a13c52b" | ||
integrity sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg== | ||
dependencies: | ||
ms "2.1.2" | ||
|
||
|
@@ -13334,6 +13334,13 @@ [email protected]: | |
dependencies: | ||
ms "2.1.2" | ||
|
||
[email protected]: | ||
version "4.3.4" | ||
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" | ||
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== | ||
dependencies: | ||
ms "2.1.2" | ||
|
||
debug@^3.1.0, debug@^3.2.6, debug@^3.2.7: | ||
version "3.2.7" | ||
resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" | ||
|
@@ -27929,14 +27936,14 @@ simple-get@^4.0.0: | |
once "^1.3.1" | ||
simple-concat "^1.0.0" | ||
|
||
simple-git@3.16.0: | ||
version "3.16.0" | ||
resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-3.16.0.tgz#421773e24680f5716999cc4a1d60127b4b6a9dec" | ||
integrity sha512-zuWYsOLEhbJRWVxpjdiXl6eyAyGo/KzVW+KFhhw9MqEEJttcq+32jTWSGyxTdf9e/YCohxRE+9xpWFj9FdiJNw== | ||
simple-git@3.25.0: | ||
version "3.25.0" | ||
resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-3.25.0.tgz#3666e76d6831f0583dc380645945b97e0ac4aab6" | ||
integrity sha512-KIY5sBnzc4yEcJXW7Tdv4viEz8KyG+nU0hay+DWZasvdFOYKeUZ6Xc25LUHHjw0tinPT7O1eY6pzX7pRT1K8rw== | ||
dependencies: | ||
"@kwsites/file-exists" "^1.1.1" | ||
"@kwsites/promise-deferred" "^1.1.1" | ||
debug "^4.3.4" | ||
debug "^4.3.5" | ||
|
||
simple-swizzle@^0.2.2: | ||
version "0.2.2" | ||
|
619a9ab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux arm64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
619a9ab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
619a9ab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux arm64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
619a9ab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
619a9ab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin arm64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
619a9ab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux arm64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
619a9ab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin arm64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
619a9ab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
619a9ab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin arm64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
619a9ab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
619a9ab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
619a9ab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
619a9ab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux arm64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
619a9ab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin arm64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
619a9ab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally: