Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
Renovate Bot
renovate
Commits
34061cf5
Commit
34061cf5
authored
6 years ago
by
Rhys Arkins
Browse files
Options
Downloads
Patches
Plain Diff
feat: go datasource getDigest
Closes #2603
parent
c0e8e51b
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/datasource/go.js
+11
-0
11 additions, 0 deletions
lib/datasource/go.js
test/datasource/go.spec.js
+19
-0
19 additions, 0 deletions
test/datasource/go.spec.js
with
30 additions
and
0 deletions
lib/datasource/go.js
+
11
−
0
View file @
34061cf5
...
...
@@ -3,6 +3,7 @@ const github = require('./github');
module
.
exports
=
{
getPkgReleases
,
getDigest
,
};
async
function
getSourcePurl
(
name
)
{
...
...
@@ -53,3 +54,13 @@ async function getPkgReleases(purl, config) {
}
return
null
;
}
async
function
getDigest
(
config
)
{
const
githubPurl
=
await
getSourcePurl
(
config
.
depName
);
if
(
githubPurl
)
{
const
githubRepo
=
githubPurl
.
fullname
;
const
digest
=
await
github
.
getDigest
({
...
config
,
githubRepo
});
return
digest
;
}
return
null
;
}
This diff is collapsed.
Click to expand it.
test/datasource/go.spec.js
+
19
−
0
View file @
34061cf5
const
got
=
require
(
'
got
'
);
const
datasource
=
require
(
'
../../lib/datasource
'
);
const
github
=
require
(
'
../../lib/datasource/github
'
);
const
go
=
require
(
'
../../lib/datasource/go
'
);
jest
.
mock
(
'
got
'
);
jest
.
mock
(
'
../../lib/datasource/github
'
);
...
...
@@ -19,6 +20,24 @@ Nothing to see here; <a href="https://godoc.org/golang.org/x/text">move along</a
</html>`
;
describe
(
'
datasource/go
'
,
()
=>
{
describe
(
'
getPkgReleases
'
,
()
=>
{
it
(
'
returns null for wrong name
'
,
async
()
=>
{
got
.
mockReturnValueOnce
({
body
:
res1
,
});
github
.
getDigest
.
mockReturnValueOnce
(
'
abcdefabcdefabcdefabcdef
'
);
const
res
=
await
go
.
getDigest
({
depName
:
'
golang.org/y/text
'
},
null
);
expect
(
res
).
toBeNull
();
});
it
(
'
returns digest
'
,
async
()
=>
{
got
.
mockReturnValueOnce
({
body
:
res1
,
});
github
.
getDigest
.
mockReturnValueOnce
(
'
abcdefabcdefabcdefabcdef
'
);
const
res
=
await
go
.
getDigest
({
depName
:
'
golang.org/x/text
'
},
null
);
expect
(
res
).
toBe
(
'
abcdefabcdefabcdefabcdef
'
);
});
});
describe
(
'
getPkgReleases
'
,
()
=>
{
it
(
'
returns null for empty result
'
,
async
()
=>
{
got
.
mockReturnValueOnce
(
null
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment