-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: error out when projectOwner & projectName is not set in .all-con…
…tributorsrc file. (#80) * error message when no project name and project owner is added in the init command * moved error message away from init prompt * 1. placed json parse in try catch 2. added check for owner and name in getcontributionsfromgithub before constructing url * added check before config file is written * changes as per #80 (review) * uncommented code * tests added * Added myself to contributors table * test inside utils were moved to github in master branch * changes to validation check, instead of checking for empty string to null obj value * typo fixed * unnecisary check.js file removed
- Loading branch information
1 parent
1562a37
commit c4a0484
Showing
3 changed files
with
40 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,43 @@ | ||
import configFile from '../config-file' | ||
|
||
const absentFile = './abc' | ||
const expected = `Configuration file not found: ${absentFile}` | ||
const absentConfileFileExpected = `Configuration file not found: ${absentFile}` | ||
const incompleteConfigFilePath = './.all-contributorsrc' | ||
const NoOwnerConfigFile = { | ||
projectOwner: '', | ||
projectName: 'all-contributors-cli', | ||
imageSize: 100, | ||
commit: false, | ||
contributorsPerLine: 6, | ||
contributors: [], | ||
} | ||
const NoNameConfigFile = { | ||
projectOwner: 'jfmengels', | ||
projectName: '', | ||
imageSize: 100, | ||
commit: false, | ||
contributorsPerLine: 6, | ||
contributors: [], | ||
} | ||
|
||
test('Reading an absent configuration file throws a helpful error', () => { | ||
expect(() => configFile.readConfig(absentFile)).toThrowError(expected) | ||
expect(() => configFile.readConfig(absentFile)).toThrowError( | ||
absentConfileFileExpected, | ||
) | ||
}) | ||
|
||
test('Writing contributors in an absent configuration file throws a helpful error', async () => { | ||
const resolvedError = await configFile | ||
.writeContributors(absentFile, []) | ||
.catch(e => e) | ||
expect(resolvedError.message).toBe(expected) | ||
expect(resolvedError.message).toBe(absentConfileFileExpected) | ||
}) | ||
|
||
test('Should throw error and not allow editing config file if project name or owner is not set', () => { | ||
expect(() => | ||
configFile.writeConfig(incompleteConfigFilePath, NoOwnerConfigFile), | ||
).toThrow(`Error! Project owner is not set in ${incompleteConfigFilePath}`) | ||
expect(() => | ||
configFile.writeConfig(incompleteConfigFilePath, NoNameConfigFile), | ||
).toThrow(`Error! Project name is not set in ${incompleteConfigFilePath}`) | ||
}) |
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