Skip to content

Commit e3b4e3a

Browse files
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
1 parent 2c0e3fe commit e3b4e3a

File tree

2 files changed

+47
-3
lines changed

2 files changed

+47
-3
lines changed

pkg/artifacts/arifacts_v4.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ type ArtifactContext struct {
121121
}
122122

123123
func artifactNameToID(s string) int64 {
124-
h := fnv.New64a()
124+
h := fnv.New32a()
125125
h.Write([]byte(s))
126-
return int64(h.Sum64())
126+
return int64(h.Sum32())
127127
}
128128

129129
func (c ArtifactContext) Error(status int, _ ...interface{}) {
@@ -376,7 +376,7 @@ func (r *artifactV4Routes) listArtifacts(ctx *ArtifactContext) {
376376

377377
for _, entry := range entries {
378378
id := artifactNameToID(entry.Name())
379-
if (req.NameFilter == nil || req.NameFilter.Value == entry.Name()) || (req.IdFilter == nil || req.IdFilter.Value == id) {
379+
if (req.NameFilter == nil || req.NameFilter.Value == entry.Name()) && (req.IdFilter == nil || req.IdFilter.Value == id) {
380380
data := &ListArtifactsResponse_MonolithArtifact{
381381
Name: entry.Name(),
382382
CreatedAt: timestamppb.Now(),

pkg/artifacts/testdata/v4/artifacts.yml

+44
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,29 @@ jobs:
1717
strategy:
1818
${{ tojson(strategy) }}
1919
shell: cp {0} context.txt
20+
- run: echo Artifact2 > data.txt
21+
2022
- uses: actions/upload-artifact@v4
2123
with:
2224
name: test
2325
path: context.txt
2426

27+
- uses: actions/upload-artifact@v4
28+
with:
29+
name: test2
30+
path: data.txt
31+
2532
- uses: actions/download-artifact@v4
2633
with:
2734
name: test
2835
path: out
2936
- run: cat out/context.txt
37+
38+
- name: assert
39+
run: |
40+
[[ "$(cat context.txt)" = "$(cat out/context.txt)" ]] || exit 1
41+
shell: bash
42+
3043
- run: |
3144
No content
3245
shell: cp {0} context.txt
@@ -41,3 +54,34 @@ jobs:
4154
name: test
4255
path: out2
4356
- run: cat out2/context.txt
57+
58+
- name: assert 2
59+
run: |
60+
[[ "$(cat context.txt)" = "$(cat out2/context.txt)" ]] || exit 1
61+
shell: bash
62+
63+
- uses: actions/download-artifact@v4
64+
with:
65+
name: test2
66+
path: out3
67+
- run: cat out3/data.txt
68+
69+
- name: assert 3
70+
run: |
71+
[[ "$(cat data.txt)" = "$(cat out3/data.txt)" ]] || exit 1
72+
shell: bash
73+
74+
- uses: actions/download-artifact@v4
75+
with:
76+
pattern: "test*"
77+
path: out4
78+
merge-multiple: true
79+
80+
- run: cat out4/data.txt
81+
- run: cat out4/context.txt
82+
83+
- name: assert 4
84+
run: |
85+
[[ "$(cat context.txt)" = "$(cat out4/context.txt)" ]] || exit 1
86+
[[ "$(cat data.txt)" = "$(cat out4/data.txt)" ]] || exit 1
87+
shell: bash

0 commit comments

Comments
 (0)