Skip to content

Commit

Permalink
clean test that fails because of fs-extra ensureSymLink but
Browse files Browse the repository at this point in the history
  • Loading branch information
jandockx committed Apr 2, 2024
1 parent 3d67d31 commit 0556cef
Showing 1 changed file with 12 additions and 40 deletions.
52 changes: 12 additions & 40 deletions test/30.Remote/60.link.test.js
Expand Up @@ -2,9 +2,9 @@

const { Remote } = require('../../lib/Remote')
const { idInService, owner, repositoryName, serviceRun, serviceProgrammaticName } = require('../_constants')
const { remove, ensureFile, pathExists, ensureSymlink } = require('fs-extra')
const { remove, ensureFile, pathExists } = require('fs-extra')
const testName = require('../_testName')(module)
const { join, relative, dirname } = require('node:path')
const { join } = require('node:path')
const { utcNow } = require('../../lib/util/time')
const { makeISODatePathCompatible } = require('../../lib/util/makeISODatePathCompatible')
const { shouldBeGitSymLinkProgressStep } = require('./GitSymLinkProgressStepCommon')
Expand Down Expand Up @@ -49,51 +49,23 @@ describe(testName, function () {
await pathExists(this.absoluteTargetFilePathViaSymLink).should.be.resolvedWith(true)
})

it.only('can create a symbolic link twice when the target exists', async function () {
const firstRelativeGitSymLinkReference = this.subject.gitSymLinkReference
console.log(firstRelativeGitSymLinkReference)
const firstAbsoluteGitSymLinkReference = this.subject.serviceRun.absolutePath(
join(dirname(this.subject.gitSymLinkPath), firstRelativeGitSymLinkReference)
)
console.log(firstAbsoluteGitSymLinkReference)
firstAbsoluteGitSymLinkReference.should.equal(this.absoluteTargetPath)
await pathExists(firstAbsoluteGitSymLinkReference).should.be.resolvedWith(true)
/* NOTE: This test is triggered by a bug in `fs-extra ensureSymLink`, registered at
https://github.com/jprichardson/node-fs-extra/issues/1038
It validates that our workaround works. */
it('can create a symbolic link twice when the target exists', async function () {
await pathExists(this.absoluteTargetPath).should.be.resolvedWith(true)

const result1 = await this.subject.ensureGitSymLink().should.be.resolved()
shouldBeGitSymLinkProgressStep(result1, false, false)

await pathExists(this.absoluteSymLinkPath).should.be.resolvedWith(true)
await pathExists(this.absoluteTargetFilePathViaSymLink).should.be.resolvedWith(true)

const secondRelativeGitSymLinkReference = this.subject.gitSymLinkReference
console.log(secondRelativeGitSymLinkReference)
secondRelativeGitSymLinkReference.should.equal(firstRelativeGitSymLinkReference)
const secondAbsoluteGitSymLinkReference = this.subject.serviceRun.absolutePath(
join(dirname(this.subject.gitSymLinkPath), secondRelativeGitSymLinkReference)
)
console.log(secondAbsoluteGitSymLinkReference)
secondAbsoluteGitSymLinkReference.should.equal(this.absoluteTargetPath)
await pathExists(secondAbsoluteGitSymLinkReference).should.be.resolvedWith(true)

await ensureSymlink(secondAbsoluteGitSymLinkReference, this.absoluteSymLinkPath, 'dir')

const relativeVersionOfTheSecondAbsoluteGitSymLinkReference = relative(
dirname(this.absoluteSymLinkPath),
secondAbsoluteGitSymLinkReference
)
console.log(relativeVersionOfTheSecondAbsoluteGitSymLinkReference)
relativeVersionOfTheSecondAbsoluteGitSymLinkReference.should.equal(this.subject.gitSymLinkReference)

await ensureSymlink(relativeVersionOfTheSecondAbsoluteGitSymLinkReference, this.absoluteSymLinkPath, 'dir')

// const originalReference = this.subject.gitSymLinkReference
// const changedReference = join('..', originalReference)
// console.log(changedReference)
// this.gitSymLinkReferenceStub = sinon.stub(this.subject, 'gitSymLinkReference').value(changedReference)
//
// const result2 = await this.subject.ensureGitSymLink().should.be.resolved()
// shouldBeGitSymLinkProgressStep(result2, false, true)
//
await pathExists(this.absoluteTargetPath).should.be.resolvedWith(true)

const result2 = await this.subject.ensureGitSymLink().should.be.resolved()
shouldBeGitSymLinkProgressStep(result2, false, true)

await pathExists(this.absoluteSymLinkPath).should.be.resolvedWith(true)
await pathExists(this.absoluteTargetFilePathViaSymLink).should.be.resolvedWith(true)
})
Expand Down

0 comments on commit 0556cef

Please sign in to comment.