@@ -2,7 +2,8 @@ import * as updateMetadata from './update_metadata'
2
2
3
3
test ( 'it returns an empty array for a blank string' , async ( ) => {
4
4
const getAlert = async ( ) => Promise . resolve ( { alertState : 'DISMISSED' , ghsaId : 'GHSA-III-BBB' , cvss : 4.6 } )
5
- expect ( updateMetadata . parse ( '' , 'dependabot/nuget/coffee-rails' , 'main' , getAlert ) ) . resolves . toEqual ( [ ] )
5
+ const getScore = async ( ) => Promise . resolve ( 43 )
6
+ expect ( updateMetadata . parse ( '' , 'dependabot/nuget/coffee-rails' , 'main' , getAlert , getScore ) ) . resolves . toEqual ( [ ] )
6
7
} )
7
8
8
9
test ( 'it returns an empty array for commit message with no dependabot yaml fragment' , async ( ) => {
@@ -14,7 +15,8 @@ test('it returns an empty array for commit message with no dependabot yaml fragm
14
15
Signed-off-by: dependabot[bot] <[email protected] >`
15
16
16
17
const getAlert = async ( ) => Promise . resolve ( { alertState : 'DISMISSED' , ghsaId : 'GHSA-III-BBB' , cvss : 4.6 } )
17
- expect ( updateMetadata . parse ( commitMessage , 'dependabot/nuget/coffee-rails' , 'main' , getAlert ) ) . resolves . toEqual ( [ ] )
18
+ const getScore = async ( ) => Promise . resolve ( 43 )
19
+ expect ( updateMetadata . parse ( commitMessage , 'dependabot/nuget/coffee-rails' , 'main' , getAlert , getScore ) ) . resolves . toEqual ( [ ] )
18
20
} )
19
21
20
22
test ( 'it returns the updated dependency information when there is a yaml fragment' , async ( ) => {
@@ -34,7 +36,8 @@ test('it returns the updated dependency information when there is a yaml fragmen
34
36
'Signed-off-by: dependabot[bot] <[email protected] >'
35
37
36
38
const getAlert = async ( ) => Promise . resolve ( { alertState : 'DISMISSED' , ghsaId : 'GHSA-III-BBB' , cvss : 4.6 } )
37
- const updatedDependencies = await updateMetadata . parse ( commitMessage , 'dependabot/nuget/coffee-rails' , 'main' , getAlert )
39
+ const getScore = async ( ) => Promise . resolve ( 43 )
40
+ const updatedDependencies = await updateMetadata . parse ( commitMessage , 'dependabot/nuget/coffee-rails' , 'main' , getAlert , getScore )
38
41
39
42
expect ( updatedDependencies ) . toHaveLength ( 1 )
40
43
@@ -46,6 +49,7 @@ test('it returns the updated dependency information when there is a yaml fragmen
46
49
expect ( updatedDependencies [ 0 ] . targetBranch ) . toEqual ( 'main' )
47
50
expect ( updatedDependencies [ 0 ] . prevVersion ) . toEqual ( '4.0.1' )
48
51
expect ( updatedDependencies [ 0 ] . newVersion ) . toEqual ( '4.2.2' )
52
+ expect ( updatedDependencies [ 0 ] . compatScore ) . toEqual ( 43 )
49
53
expect ( updatedDependencies [ 0 ] . alertState ) . toEqual ( 'DISMISSED' )
50
54
expect ( updatedDependencies [ 0 ] . ghsaId ) . toEqual ( 'GHSA-III-BBB' )
51
55
expect ( updatedDependencies [ 0 ] . cvss ) . toEqual ( 4.6 )
@@ -78,7 +82,15 @@ test('it supports multiple dependencies within a single fragment', async () => {
78
82
return Promise . resolve ( { alertState : '' , ghsaId : '' , cvss : 0 } )
79
83
}
80
84
81
- const updatedDependencies = await updateMetadata . parse ( commitMessage , 'dependabot/nuget/api/main/coffee-rails' , 'main' , getAlert )
85
+ const getScore = async ( name : string ) => {
86
+ if ( name === 'coffee-rails' ) {
87
+ return Promise . resolve ( 34 )
88
+ }
89
+
90
+ return Promise . resolve ( 0 )
91
+ }
92
+
93
+ const updatedDependencies = await updateMetadata . parse ( commitMessage , 'dependabot/nuget/api/main/coffee-rails' , 'main' , getAlert , getScore )
82
94
83
95
expect ( updatedDependencies ) . toHaveLength ( 2 )
84
96
@@ -90,6 +102,7 @@ test('it supports multiple dependencies within a single fragment', async () => {
90
102
expect ( updatedDependencies [ 0 ] . targetBranch ) . toEqual ( 'main' )
91
103
expect ( updatedDependencies [ 0 ] . prevVersion ) . toEqual ( '4.0.1' )
92
104
expect ( updatedDependencies [ 0 ] . newVersion ) . toEqual ( '4.2.2' )
105
+ expect ( updatedDependencies [ 0 ] . compatScore ) . toEqual ( 34 )
93
106
expect ( updatedDependencies [ 0 ] . alertState ) . toEqual ( 'DISMISSED' )
94
107
expect ( updatedDependencies [ 0 ] . ghsaId ) . toEqual ( 'GHSA-III-BBB' )
95
108
expect ( updatedDependencies [ 0 ] . cvss ) . toEqual ( 4.6 )
@@ -101,7 +114,7 @@ test('it supports multiple dependencies within a single fragment', async () => {
101
114
expect ( updatedDependencies [ 1 ] . packageEcosystem ) . toEqual ( 'nuget' )
102
115
expect ( updatedDependencies [ 1 ] . targetBranch ) . toEqual ( 'main' )
103
116
expect ( updatedDependencies [ 1 ] . prevVersion ) . toEqual ( '' )
104
- expect ( updatedDependencies [ 1 ] . newVersion ) . toEqual ( '' )
117
+ expect ( updatedDependencies [ 1 ] . compatScore ) . toEqual ( 0 )
105
118
expect ( updatedDependencies [ 1 ] . alertState ) . toEqual ( '' )
106
119
expect ( updatedDependencies [ 1 ] . ghsaId ) . toEqual ( '' )
107
120
expect ( updatedDependencies [ 1 ] . cvss ) . toEqual ( 0 )
@@ -129,7 +142,7 @@ test('it only returns information within the first fragment if there are multipl
129
142
'\n' +
130
143
'Signed-off-by: dependabot[bot] <[email protected] >'
131
144
132
- const updatedDependencies = await updateMetadata . parse ( commitMessage , 'dependabot|nuget|coffee-rails' , 'main' , undefined )
145
+ const updatedDependencies = await updateMetadata . parse ( commitMessage , 'dependabot|nuget|coffee-rails' , 'main' , undefined , undefined )
133
146
134
147
expect ( updatedDependencies ) . toHaveLength ( 1 )
135
148
@@ -141,6 +154,7 @@ test('it only returns information within the first fragment if there are multipl
141
154
expect ( updatedDependencies [ 0 ] . targetBranch ) . toEqual ( 'main' )
142
155
expect ( updatedDependencies [ 0 ] . prevVersion ) . toEqual ( '' )
143
156
expect ( updatedDependencies [ 0 ] . newVersion ) . toEqual ( '' )
157
+ expect ( updatedDependencies [ 0 ] . compatScore ) . toEqual ( 0 )
144
158
expect ( updatedDependencies [ 0 ] . alertState ) . toEqual ( '' )
145
159
expect ( updatedDependencies [ 0 ] . ghsaId ) . toEqual ( '' )
146
160
expect ( updatedDependencies [ 0 ] . cvss ) . toEqual ( 0 )
@@ -162,7 +176,8 @@ test('it properly handles dependencies which contain slashes', async () => {
162
176
'Signed-off-by: dependabot[bot] <[email protected] >'
163
177
164
178
const getAlert = async ( ) => Promise . resolve ( { alertState : '' , ghsaId : '' , cvss : 0 } )
165
- const updatedDependencies = await updateMetadata . parse ( commitMessage , 'dependabot/nuget/api/rails/coffee' , 'main' , getAlert )
179
+ const getScore = async ( ) => Promise . resolve ( 0 )
180
+ const updatedDependencies = await updateMetadata . parse ( commitMessage , 'dependabot/nuget/api/rails/coffee' , 'main' , getAlert , getScore )
166
181
167
182
expect ( updatedDependencies ) . toHaveLength ( 1 )
168
183
@@ -174,6 +189,7 @@ test('it properly handles dependencies which contain slashes', async () => {
174
189
expect ( updatedDependencies [ 0 ] . targetBranch ) . toEqual ( 'main' )
175
190
expect ( updatedDependencies [ 0 ] . prevVersion ) . toEqual ( '' )
176
191
expect ( updatedDependencies [ 0 ] . newVersion ) . toEqual ( '' )
192
+ expect ( updatedDependencies [ 0 ] . compatScore ) . toEqual ( 0 )
177
193
expect ( updatedDependencies [ 0 ] . alertState ) . toEqual ( '' )
178
194
expect ( updatedDependencies [ 0 ] . ghsaId ) . toEqual ( '' )
179
195
expect ( updatedDependencies [ 0 ] . cvss ) . toEqual ( 0 )
0 commit comments