Skip to content

Commit 343bc69

Browse files
author
Guillermo C. Martínez
committed
chore: fixing database seeding after store refactor
1 parent be1dc4b commit 343bc69

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

__tests__/cli/workflows.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ beforeAll(() => {
2222
({
2323
getAllProjects,
2424
getAllGithubOrganizations: getAllGithubOrgs,
25-
addGithubOrg,
25+
addGithubOrganization: addGithubOrg,
2626
addProject,
2727
getAllGithubRepositories: getAllGithubRepos,
28-
addGithubRepo
29-
} = initializeStore(knex))
28+
addGithubRepo,
29+
} = initializeStore(knex));
3030
})
3131
beforeEach(async () => {
3232
await resetDatabase(knex)

src/database/seeds/index.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,32 @@ const {
55
} = require('../../../__fixtures__')
66
const {
77
resetDatabase,
8-
addProject,
9-
addGithubOrg,
10-
addGithubRepo,
11-
addOSSFScorecardResult
8+
initializeStore
129
} = require('../../../__utils__')
1310
const { github, ossf } = require('../../providers')
1411

1512
exports.seed = async (knex) => {
1613
// Clean up the database
1714
await resetDatabase(knex)
15+
const {
16+
addProject,
17+
addGithubOrganization: addGithubOrg,
18+
addGithubRepo,
19+
addOSSFScorecardResult,
20+
} = initializeStore(knex);
1821

1922
// Add a project
20-
const project = await addProject(knex, {
23+
const [project] = await addProject({
2124
name: 'github',
2225
category: 'impact'
2326
})
2427

2528
// Add a GitHub organization
26-
const githubOrg = await addGithubOrg(knex, { ...github.mappers.org(sampleGithubOrg), project_id: project.id })
29+
const [githubOrg] = await addGithubOrg({ ...github.mappers.org(sampleGithubOrg), project_id: project.id })
2730

2831
// Add GitHub repository
29-
const githubRepo = await addGithubRepo(knex, { ...github.mappers.repo(sampleGithubRepository), github_organization_id: githubOrg.id })
32+
const [githubRepo] = await addGithubRepo({ ...github.mappers.repo(sampleGithubRepository), github_organization_id: githubOrg.id })
3033

3134
// Add OSSF Scorecard results
32-
await addOSSFScorecardResult(knex, { ...ossf.mappers.result(sampleOSSFScorecardResult), github_repository_id: githubRepo.id, analysis_execution_time: 19123 })
35+
await addOSSFScorecardResult({ ...ossf.mappers.result(sampleOSSFScorecardResult), github_repository_id: githubRepo.id, analysis_execution_time: 19123 })
3336
}

src/store/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ const initializeStore = (knex) => {
143143
addResult: (result) => addTo('compliance_checks_results', result),
144144
addSSoftwareDesignTraining: (data) => addTo('software_design_training', data),
145145
addGithubRepo: (repo) => addTo('github_repositories', repo),
146-
addGithubOrg: (org) => addTo('github_organizations', org),
147-
upsertComplianceCheckResult: upsertComplianceCheckResult(knex),
148-
upsertOSSFScorecard: upsertOSSFScorecard(knex)
146+
addOSSFScorecardResult: (ossf) => addTo('ossf_scorecard_results', ossf),
147+
upsertOSSFScorecard: upsertOSSFScorecard(knex),
148+
upsertComplianceCheckResult: upsertComplianceCheckResult(knex)
149149
}
150150
}
151151

0 commit comments

Comments
 (0)