add test for listartifacts v4 filter (#2507)
* add test for listartifacts v4 filter * fixes a defect of last change * Update artifacts.yml * use 32bit ids after cast to double we have a loss * Update artifacts.yml
This commit is contained in:
@@ -121,9 +121,9 @@ type ArtifactContext struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func artifactNameToID(s string) int64 {
|
func artifactNameToID(s string) int64 {
|
||||||
h := fnv.New64a()
|
h := fnv.New32a()
|
||||||
h.Write([]byte(s))
|
h.Write([]byte(s))
|
||||||
return int64(h.Sum64())
|
return int64(h.Sum32())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c ArtifactContext) Error(status int, _ ...interface{}) {
|
func (c ArtifactContext) Error(status int, _ ...interface{}) {
|
||||||
@@ -376,7 +376,7 @@ func (r *artifactV4Routes) listArtifacts(ctx *ArtifactContext) {
|
|||||||
|
|
||||||
for _, entry := range entries {
|
for _, entry := range entries {
|
||||||
id := artifactNameToID(entry.Name())
|
id := artifactNameToID(entry.Name())
|
||||||
if (req.NameFilter == nil || req.NameFilter.Value == entry.Name()) || (req.IdFilter == nil || req.IdFilter.Value == id) {
|
if (req.NameFilter == nil || req.NameFilter.Value == entry.Name()) && (req.IdFilter == nil || req.IdFilter.Value == id) {
|
||||||
data := &ListArtifactsResponse_MonolithArtifact{
|
data := &ListArtifactsResponse_MonolithArtifact{
|
||||||
Name: entry.Name(),
|
Name: entry.Name(),
|
||||||
CreatedAt: timestamppb.Now(),
|
CreatedAt: timestamppb.Now(),
|
||||||
|
|||||||
44
pkg/artifacts/testdata/v4/artifacts.yml
vendored
44
pkg/artifacts/testdata/v4/artifacts.yml
vendored
@@ -17,16 +17,29 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
${{ tojson(strategy) }}
|
${{ tojson(strategy) }}
|
||||||
shell: cp {0} context.txt
|
shell: cp {0} context.txt
|
||||||
|
- run: echo Artifact2 > data.txt
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: test
|
name: test
|
||||||
path: context.txt
|
path: context.txt
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: test2
|
||||||
|
path: data.txt
|
||||||
|
|
||||||
- uses: actions/download-artifact@v4
|
- uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: test
|
name: test
|
||||||
path: out
|
path: out
|
||||||
- run: cat out/context.txt
|
- run: cat out/context.txt
|
||||||
|
|
||||||
|
- name: assert
|
||||||
|
run: |
|
||||||
|
[[ "$(cat context.txt)" = "$(cat out/context.txt)" ]] || exit 1
|
||||||
|
shell: bash
|
||||||
|
|
||||||
- run: |
|
- run: |
|
||||||
No content
|
No content
|
||||||
shell: cp {0} context.txt
|
shell: cp {0} context.txt
|
||||||
@@ -41,3 +54,34 @@ jobs:
|
|||||||
name: test
|
name: test
|
||||||
path: out2
|
path: out2
|
||||||
- run: cat out2/context.txt
|
- run: cat out2/context.txt
|
||||||
|
|
||||||
|
- name: assert 2
|
||||||
|
run: |
|
||||||
|
[[ "$(cat context.txt)" = "$(cat out2/context.txt)" ]] || exit 1
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: test2
|
||||||
|
path: out3
|
||||||
|
- run: cat out3/data.txt
|
||||||
|
|
||||||
|
- name: assert 3
|
||||||
|
run: |
|
||||||
|
[[ "$(cat data.txt)" = "$(cat out3/data.txt)" ]] || exit 1
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
pattern: "test*"
|
||||||
|
path: out4
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
|
- run: cat out4/data.txt
|
||||||
|
- run: cat out4/context.txt
|
||||||
|
|
||||||
|
- name: assert 4
|
||||||
|
run: |
|
||||||
|
[[ "$(cat context.txt)" = "$(cat out4/context.txt)" ]] || exit 1
|
||||||
|
[[ "$(cat data.txt)" = "$(cat out4/data.txt)" ]] || exit 1
|
||||||
|
shell: bash
|
||||||
|
|||||||
Reference in New Issue
Block a user