Skip to content

Commit

Permalink
Merge pull request #31 from secure-dashboards/feat/add-repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
UlisesGascon authored Dec 5, 2024
2 parents bd6452f + ad4b07b commit c96c7b6
Show file tree
Hide file tree
Showing 4 changed files with 3,645 additions and 3,771 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,7 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*


# CUSTOM
IGNORE/
54 changes: 15 additions & 39 deletions __tests__/cli/workflows.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,21 @@ describe('list - Non-Interactive Mode', () => {
})
})

describe('run update-github-orgs - Interactive Mode', () => {
describe('run GENERIC - Non-Interactive Mode', () => {
test('Should throw an error when invalid name is provided', async () => {
await expect(runWorkflowCommand(knex, { name: 'invented' }))
.rejects
.toThrow('Invalid workflow name. Please enter a valid workflow name.')
})

test('Should throw an error when no name is provided', async () => {
await expect(runWorkflowCommand(knex, { name: undefined }))
.rejects
.toThrow('Invalid workflow name. Please enter a valid workflow name.')
})
})

describe('run update-github-orgs', () => {
// Mock inquirer for testing
jest.spyOn(inquirer, 'prompt').mockImplementation(async (questions) => {
const questionMap = {
Expand Down Expand Up @@ -74,41 +88,3 @@ describe('run update-github-orgs - Interactive Mode', () => {

test.todo('Should throw an error when the Github API is not available')
})

describe('run update-github-orgs - Non-Interactive Mode', () => {
// Mock inquirer for testing
jest.spyOn(inquirer, 'prompt').mockImplementation(async (questions) => {
const questionMap = {
'What is the name of the workflow?': 'update-github-orgs'
}
return questions.reduce((acc, question) => {
acc[question.name] = questionMap[question.message]
return acc
}, {})
})

test('Should throw an error when invalid name is provided', async () => {
await expect(runWorkflowCommand(knex, { name: 'invented' }))
.rejects
.toThrow('Invalid workflow name. Please enter a valid workflow name.')
})

test('Should throw an error when no name is provided', async () => {
await expect(runWorkflowCommand(knex, { name: undefined }))
.rejects
.toThrow('Invalid workflow name. Please enter a valid workflow name.')
})

test('Should throw an error when no Github orgs are stored in the database', async () => {
const projects = await getAllProjects(knex)
expect(projects.length).toBe(0)
const githubOrgs = await getAllGithubOrgs(knex)
expect(githubOrgs.length).toBe(0)
await expect(runWorkflowCommand(knex, { name: 'update-github-orgs' }))
.rejects
.toThrow('No organizations found. Please add organizations/projects before running this workflow.')
})

test.todo('Should update the project with new information available')
test.todo('Should throw an error when the Github API is not available')
})
5 changes: 4 additions & 1 deletion src/schemas/githubListOrgRepos.json
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,10 @@
"type": "string"
},
"url": {
"type": "string"
"type": [
"string",
"null"
]
},
"node_id": {
"type": "string"
Expand Down
Loading

0 comments on commit c96c7b6

Please sign in to comment.