Skip to content

Commit c74971e

Browse files
committed
Fix repository tests that fail when run in fork of atom/atom
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. 😅
1 parent b9966ac commit c74971e

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

spec/fixtures/git/master.git/config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
bare = false
55
logallrefupdates = true
66
ignorecase = true
7+
[remote "origin"]
8+
url = https://github.com/example-user/example-repo.git
9+
fetch = +refs/heads/*:refs/remotes/origin/*

spec/project-spec.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,10 +1000,13 @@ describe('Project', () => {
10001000
const observed = []
10011001
const disposable = atom.project.onDidAddRepository((repo) => observed.push(repo))
10021002

1003-
const repositoryPath = path.join(__dirname, '..')
1004-
atom.project.addPath(repositoryPath)
1003+
const projectRootPath = temp.mkdirSync()
1004+
const fixtureRepoPath = fs.absolute(path.join(__dirname, 'fixtures', 'git', 'master.git'))
1005+
fs.copySync(fixtureRepoPath, path.join(projectRootPath, '.git'))
1006+
1007+
atom.project.addPath(projectRootPath)
10051008
expect(observed.length).toBe(1)
1006-
expect(observed[0].getOriginURL()).toContain('atom/atom')
1009+
expect(observed[0].getOriginURL()).toEqual('https://github.com/example-user/example-repo.git')
10071010

10081011
disposable.dispose()
10091012
})
@@ -1012,9 +1015,16 @@ describe('Project', () => {
10121015
const observed = []
10131016
const disposable = atom.project.onDidAddRepository((repo) => observed.push(repo))
10141017

1015-
atom.project.addPath(__dirname)
1018+
const projectRootPath = temp.mkdirSync()
1019+
const fixtureRepoPath = fs.absolute(path.join(__dirname, 'fixtures', 'git', 'master.git'))
1020+
fs.copySync(fixtureRepoPath, path.join(projectRootPath, '.git'))
1021+
1022+
const projectSubDirPath = path.join(projectRootPath, 'sub-dir')
1023+
fs.mkdirSync(projectSubDirPath)
1024+
1025+
atom.project.addPath(projectSubDirPath)
10161026
expect(observed.length).toBe(1)
1017-
expect(observed[0].getOriginURL()).toContain('atom/atom')
1027+
expect(observed[0].getOriginURL()).toEqual('https://github.com/example-user/example-repo.git')
10181028

10191029
disposable.dispose()
10201030
})

0 commit comments

Comments
 (0)