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
c449c85d
Unverified
Commit
c449c85d
authored
2 years ago
by
Jason Bedard
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
test(bazel): add tests with multiple http_archives (#17933)
parent
fb3626a4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/modules/manager/bazel/parser.spec.ts
+49
-0
49 additions, 0 deletions
lib/modules/manager/bazel/parser.spec.ts
lib/modules/manager/bazel/update.spec.ts
+118
-0
118 additions, 0 deletions
lib/modules/manager/bazel/update.spec.ts
with
167 additions
and
0 deletions
lib/modules/manager/bazel/parser.spec.ts
+
49
−
0
View file @
c449c85d
...
...
@@ -61,4 +61,53 @@ describe('modules/manager/bazel/parser', () => {
],
});
});
it
(
'
parses multiple archives
'
,
()
=>
{
const
input
=
`
http_archive(
name = "aspect_rules_js",
sha256 = "db9f446752fe4100320cf8487e8fd476b9af0adf6b99b601bcfd70b289bb0598",
strip_prefix = "rules_js-1.1.2",
url = "https://github.com/aspect-build/rules_js/archive/refs/tags/v1.1.2.tar.gz",
)
http_archive(
name = "rules_nodejs",
sha256 = "5aef09ed3279aa01d5c928e3beb248f9ad32dde6aafe6373a8c994c3ce643064",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.5.3/rules_nodejs-core-5.5.3.tar.gz"],
)`
;
const
res
=
parse
(
input
);
expect
(
res
).
toEqual
({
meta
:
[
{
data
:
{
length
:
15
,
offset
:
39
},
path
:
[
0
,
'
name
'
]
},
{
data
:
{
length
:
64
,
offset
:
77
},
path
:
[
0
,
'
sha256
'
]
},
{
data
:
{
length
:
14
,
offset
:
170
},
path
:
[
0
,
'
strip_prefix
'
]
},
{
data
:
{
length
:
72
,
offset
:
204
},
path
:
[
0
,
'
url
'
]
},
{
data
:
{
length
:
279
,
offset
:
7
},
path
:
[
0
]
},
{
data
:
{
length
:
12
,
offset
:
323
},
path
:
[
0
,
1
,
'
name
'
]
},
{
data
:
{
length
:
64
,
offset
:
356
},
path
:
[
0
,
1
,
'
sha256
'
]
},
{
data
:
{
length
:
97
,
offset
:
440
},
path
:
[
0
,
1
,
'
urls
'
,
0
]
},
{
data
:
{
length
:
255
,
offset
:
293
},
path
:
[
1
]
},
],
targets
:
[
{
rule
:
'
http_archive
'
,
name
:
'
aspect_rules_js
'
,
sha256
:
'
db9f446752fe4100320cf8487e8fd476b9af0adf6b99b601bcfd70b289bb0598
'
,
strip_prefix
:
'
rules_js-1.1.2
'
,
url
:
'
https://github.com/aspect-build/rules_js/archive/refs/tags/v1.1.2.tar.gz
'
,
},
{
rule
:
'
http_archive
'
,
name
:
'
rules_nodejs
'
,
sha256
:
'
5aef09ed3279aa01d5c928e3beb248f9ad32dde6aafe6373a8c994c3ce643064
'
,
urls
:
[
'
https://github.com/bazelbuild/rules_nodejs/releases/download/5.5.3/rules_nodejs-core-5.5.3.tar.gz
'
,
],
},
],
});
});
});
This diff is collapsed.
Click to expand it.
lib/modules/manager/bazel/update.spec.ts
+
118
−
0
View file @
c449c85d
...
...
@@ -456,4 +456,122 @@ describe('modules/manager/bazel/update', () => {
expect
(
res
).
toEqual
(
output
);
});
});
it
(
'
updates one http_archive alongside others
'
,
async
()
=>
{
const
inputHash1
=
'
5aef09ed3279aa01d5c928e3beb248f9ad32dde6aafe6373a8c994c3ce643064
'
;
const
other_http_archive
=
`
http_archive(
name = "aspect_rules_js",
sha256 = "db9f446752fe4100320cf8487e8fd476b9af0adf6b99b601bcfd70b289bb0598",
strip_prefix = "rules_js-1.1.2",
url = "https://github.com/aspect-build/rules_js/archive/refs/tags/v1.1.2.tar.gz",
)
`
.
trim
();
const
upgraded_http_archive
=
`
http_archive(
name = "rules_nodejs",
sha256 = "
${
inputHash1
}
",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.5.3/rules_nodejs-core-5.5.3.tar.gz"],
)
`
.
trim
();
const
input
=
`
${
other_http_archive
}
\n
${
upgraded_http_archive
}
`
;
const
currentValue1
=
'
5.5.3
'
;
const
newValue1
=
'
5.5.4
'
;
const
upgrade1
=
{
depName
:
'
rules_nodejs
'
,
depType
:
'
http_archive
'
,
repo
:
'
bazelbuild/rules_nodejs
'
,
managerData
:
{
def
:
upgraded_http_archive
},
currentValue
:
currentValue1
,
newValue
:
newValue1
,
};
const
tarContent1
=
Buffer
.
from
(
'
foo
'
);
const
outputHash1
=
crypto
.
createHash
(
'
sha256
'
)
.
update
(
tarContent1
)
.
digest
(
'
hex
'
);
httpMock
.
scope
(
'
https://github.com
'
)
.
get
(
'
/bazelbuild/rules_nodejs/releases/download/5.5.4/rules_nodejs-core-5.5.4.tar.gz
'
)
.
reply
(
200
,
tarContent1
);
const
output1
=
input
.
replace
(
currentValue1
,
newValue1
)
.
replace
(
currentValue1
,
newValue1
)
.
replace
(
currentValue1
,
newValue1
)
.
replace
(
inputHash1
,
outputHash1
);
const
res
=
await
updateDependency
({
fileContent
:
input
,
upgrade
:
upgrade1
,
});
expect
(
res
).
toEqual
(
output1
);
});
it
(
'
updates one http_archive alongside others with matching versions
'
,
async
()
=>
{
const
inputHash1
=
'
5aef09ed3279aa01d5c928e3beb248f9ad32dde6aafe6373a8c994c3ce643064
'
;
const
other_http_archive
=
`
http_archive(
name = "aspect_rules_js",
sha256 = "db9f446752fe4100320cf8487e8fd476b9af0adf6b99b601bcfd70b289bb0598",
strip_prefix = "rules_js-1.1.2",
url = "https://github.com/aspect-build/rules_js/archive/refs/tags/v1.1.2.tar.gz",
)`
.
trim
();
const
upgraded_http_archive
=
`
http_archive(
name = "rules_nodejs",
sha256 = "
${
inputHash1
}
",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.1.2/rules_nodejs-core-1.1.2.tar.gz"],
)
`
.
trim
();
const
input
=
`
${
other_http_archive
}
\n
${
upgraded_http_archive
}
`
;
const
currentValue1
=
'
1.1.2
'
;
const
newValue1
=
'
1.2.3
'
;
const
upgrade1
=
{
depName
:
'
rules_nodejs
'
,
depType
:
'
http_archive
'
,
repo
:
'
bazelbuild/rules_nodejs
'
,
managerData
:
{
def
:
upgraded_http_archive
},
currentValue
:
currentValue1
,
newValue
:
newValue1
,
};
const
tarContent1
=
Buffer
.
from
(
'
foo
'
);
const
outputHash1
=
crypto
.
createHash
(
'
sha256
'
)
.
update
(
tarContent1
)
.
digest
(
'
hex
'
);
httpMock
.
scope
(
'
https://github.com
'
)
.
get
(
'
/bazelbuild/rules_nodejs/releases/download/1.2.3/rules_nodejs-core-1.2.3.tar.gz
'
)
.
reply
(
200
,
tarContent1
);
const
output1
=
input
.
replace
(
`
${
currentValue1
}
/rules_nodejs-core-
${
currentValue1
}
`
,
`
${
newValue1
}
/rules_nodejs-core-
${
newValue1
}
`
)
.
replace
(
inputHash1
,
outputHash1
);
const
res
=
await
updateDependency
({
fileContent
:
input
,
upgrade
:
upgrade1
,
});
expect
(
res
).
toEqual
(
output1
);
});
});
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