Skip to content

Commit

Permalink
Changes based on review and design
Browse files Browse the repository at this point in the history
Signed-off-by: nigel brown <[email protected]>
  • Loading branch information
therealnb committed May 22, 2024
1 parent 73dc706 commit 787cdab
Show file tree
Hide file tree
Showing 5 changed files with 365 additions and 135 deletions.
41 changes: 40 additions & 1 deletion __tests__/trusty.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
ConfigurationOptions,
ConfigurationOptionsSchema
} from '../src/schemas'
import {getTrustyScores} from '../src/trusty'
import {aggregateChanges, getTrustyScores} from '../src/trusty'

const nonExistChange: Change = {
manifest: 'package.json',
Expand Down Expand Up @@ -66,6 +66,32 @@ const pipChange: Change = {
]
}

const pipV1Change: Change = {
change_type: 'removed',
manifest: 'requirements.txt',
ecosystem: 'pip',
name: 'pandas',
version: '1.1.1',
package_url: 'pkg:pypi/[email protected]',
license: 'MIT',
source_repository_url: 'github.com/some-repo',
scope: 'runtime',
vulnerabilities: []
}

const pipV2Change: Change = {
change_type: 'added',
manifest: 'requirements.txt',
ecosystem: 'pip',
name: 'pandas',
version: '1.1.2',
package_url: 'pkg:pypi/[email protected]',
license: 'MIT',
source_repository_url: 'github.com/some-repo',
scope: 'runtime',
vulnerabilities: []
}

const mavenChange: Change = {
change_type: 'added',
manifest: 'pom.xml',
Expand Down Expand Up @@ -138,3 +164,16 @@ test('Test bad list', async () => {
expect(changed).toHaveLength(changes.length)
expect(changed[0].trusty?.score).toBeGreaterThan(0)
})

test('Test update', async () => {
const changes: Changes = [
npmChange,
pipV2Change,
mavenChange,
nonExistChange,
pipV1Change
]
const updates = aggregateChanges(changes)
expect(updates[0]).not.toBeNull()
expect(updates).toHaveLength(changes.length - 1)
})
220 changes: 154 additions & 66 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 787cdab

Please sign in to comment.