From c74971e40cd8bf4a2eec18d32315495db55be051 Mon Sep 17 00:00:00 2001 From: Jason Rudolph Date: Fri, 27 Jul 2018 09:40:38 -0400 Subject: [PATCH] Fix repository tests that fail when run in fork of atom/atom MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prior to this change, these tests assumed that the local repository is a clone of atom/atom, and the tests (unintentionally) failed if the local repository was a fork of atom/atom: https://circleci.com/gh/marcomorain/atom-1/29 Instead of depending on the local clone of the atom repository for these tests, this commit updates the tests to use one of the fixture repositories. 😅 --- spec/fixtures/git/master.git/config | 3 +++ spec/project-spec.js | 20 +++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/spec/fixtures/git/master.git/config b/spec/fixtures/git/master.git/config index af107929f..c9da546d6 100644 --- a/spec/fixtures/git/master.git/config +++ b/spec/fixtures/git/master.git/config @@ -4,3 +4,6 @@ bare = false logallrefupdates = true ignorecase = true +[remote "origin"] + url = https://github.com/example-user/example-repo.git + fetch = +refs/heads/*:refs/remotes/origin/* diff --git a/spec/project-spec.js b/spec/project-spec.js index e7601253c..861a0f53a 100644 --- a/spec/project-spec.js +++ b/spec/project-spec.js @@ -1000,10 +1000,13 @@ describe('Project', () => { const observed = [] const disposable = atom.project.onDidAddRepository((repo) => observed.push(repo)) - const repositoryPath = path.join(__dirname, '..') - atom.project.addPath(repositoryPath) + const projectRootPath = temp.mkdirSync() + const fixtureRepoPath = fs.absolute(path.join(__dirname, 'fixtures', 'git', 'master.git')) + fs.copySync(fixtureRepoPath, path.join(projectRootPath, '.git')) + + atom.project.addPath(projectRootPath) expect(observed.length).toBe(1) - expect(observed[0].getOriginURL()).toContain('atom/atom') + expect(observed[0].getOriginURL()).toEqual('https://github.com/example-user/example-repo.git') disposable.dispose() }) @@ -1012,9 +1015,16 @@ describe('Project', () => { const observed = [] const disposable = atom.project.onDidAddRepository((repo) => observed.push(repo)) - atom.project.addPath(__dirname) + const projectRootPath = temp.mkdirSync() + const fixtureRepoPath = fs.absolute(path.join(__dirname, 'fixtures', 'git', 'master.git')) + fs.copySync(fixtureRepoPath, path.join(projectRootPath, '.git')) + + const projectSubDirPath = path.join(projectRootPath, 'sub-dir') + fs.mkdirSync(projectSubDirPath) + + atom.project.addPath(projectSubDirPath) expect(observed.length).toBe(1) - expect(observed[0].getOriginURL()).toContain('atom/atom') + expect(observed[0].getOriginURL()).toEqual('https://github.com/example-user/example-repo.git') disposable.dispose() })