1
- // Copyright (c) 2018-2023 , Sylabs Inc. All rights reserved.
1
+ // Copyright (c) 2018-2024 , Sylabs Inc. All rights reserved.
2
2
// This software is licensed under a 3-clause BSD license. Please consult the
3
3
// LICENSE file distributed with the sources of this project regarding your
4
4
// rights to use or distribute this software.
@@ -17,7 +17,7 @@ func TestDeleteObject(t *testing.T) {
17
17
tests := []struct {
18
18
name string
19
19
createOpts []CreateOpt
20
- id uint32
20
+ ids [] uint32
21
21
opts []DeleteOpt
22
22
wantErr error
23
23
}{
@@ -26,44 +26,104 @@ func TestDeleteObject(t *testing.T) {
26
26
createOpts : []CreateOpt {
27
27
OptCreateDeterministic (),
28
28
},
29
- id : 1 ,
29
+ ids : [] uint32 { 1 } ,
30
30
wantErr : ErrObjectNotFound ,
31
31
},
32
32
{
33
- name : "Zero" ,
33
+ name : "Compact" ,
34
+ createOpts : []CreateOpt {
35
+ OptCreateDeterministic (),
36
+ OptCreateWithDescriptors (
37
+ getDescriptorInput (t , DataGeneric , []byte {0xfa , 0xce }),
38
+ getDescriptorInput (t , DataGeneric , []byte {0xfe , 0xed }),
39
+ ),
40
+ },
41
+ ids : []uint32 {1 , 2 },
42
+ opts : []DeleteOpt {
43
+ OptDeleteCompact (true ),
44
+ },
45
+ },
46
+ {
47
+ name : "OneZero" ,
34
48
createOpts : []CreateOpt {
35
49
OptCreateDeterministic (),
36
50
OptCreateWithDescriptors (
37
51
getDescriptorInput (t , DataGeneric , []byte {0xfa , 0xce }),
52
+ getDescriptorInput (t , DataGeneric , []byte {0xfe , 0xed }),
38
53
),
39
54
},
40
- id : 1 ,
55
+ ids : [] uint32 { 1 } ,
41
56
opts : []DeleteOpt {
42
57
OptDeleteZero (true ),
43
58
},
44
59
},
45
60
{
46
- name : "Compact " ,
61
+ name : "OneCompact " ,
47
62
createOpts : []CreateOpt {
48
63
OptCreateDeterministic (),
49
64
OptCreateWithDescriptors (
50
65
getDescriptorInput (t , DataGeneric , []byte {0xfa , 0xce }),
66
+ getDescriptorInput (t , DataGeneric , []byte {0xfe , 0xed }),
51
67
),
52
68
},
53
- id : 1 ,
69
+ ids : [] uint32 { 1 } ,
54
70
opts : []DeleteOpt {
55
71
OptDeleteCompact (true ),
56
72
},
57
73
},
58
74
{
59
- name : "ZeroCompact" ,
75
+ name : "OneZeroCompact" ,
76
+ createOpts : []CreateOpt {
77
+ OptCreateDeterministic (),
78
+ OptCreateWithDescriptors (
79
+ getDescriptorInput (t , DataGeneric , []byte {0xfa , 0xce }),
80
+ getDescriptorInput (t , DataGeneric , []byte {0xfe , 0xed }),
81
+ ),
82
+ },
83
+ ids : []uint32 {1 },
84
+ opts : []DeleteOpt {
85
+ OptDeleteZero (true ),
86
+ OptDeleteCompact (true ),
87
+ },
88
+ },
89
+ {
90
+ name : "TwoZero" ,
91
+ createOpts : []CreateOpt {
92
+ OptCreateDeterministic (),
93
+ OptCreateWithDescriptors (
94
+ getDescriptorInput (t , DataGeneric , []byte {0xfa , 0xce }),
95
+ getDescriptorInput (t , DataGeneric , []byte {0xfe , 0xed }),
96
+ ),
97
+ },
98
+ ids : []uint32 {2 },
99
+ opts : []DeleteOpt {
100
+ OptDeleteZero (true ),
101
+ },
102
+ },
103
+ {
104
+ name : "TwoCompact" ,
105
+ createOpts : []CreateOpt {
106
+ OptCreateDeterministic (),
107
+ OptCreateWithDescriptors (
108
+ getDescriptorInput (t , DataGeneric , []byte {0xfa , 0xce }),
109
+ getDescriptorInput (t , DataGeneric , []byte {0xfe , 0xed }),
110
+ ),
111
+ },
112
+ ids : []uint32 {2 },
113
+ opts : []DeleteOpt {
114
+ OptDeleteCompact (true ),
115
+ },
116
+ },
117
+ {
118
+ name : "TwoZeroCompact" ,
60
119
createOpts : []CreateOpt {
61
120
OptCreateDeterministic (),
62
121
OptCreateWithDescriptors (
63
122
getDescriptorInput (t , DataGeneric , []byte {0xfa , 0xce }),
123
+ getDescriptorInput (t , DataGeneric , []byte {0xfe , 0xed }),
64
124
),
65
125
},
66
- id : 1 ,
126
+ ids : [] uint32 { 2 } ,
67
127
opts : []DeleteOpt {
68
128
OptDeleteZero (true ),
69
129
OptDeleteCompact (true ),
@@ -78,7 +138,7 @@ func TestDeleteObject(t *testing.T) {
78
138
),
79
139
OptCreateWithTime (time .Unix (946702800 , 0 )),
80
140
},
81
- id : 1 ,
141
+ ids : [] uint32 { 1 } ,
82
142
opts : []DeleteOpt {
83
143
OptDeleteDeterministic (),
84
144
},
@@ -91,7 +151,7 @@ func TestDeleteObject(t *testing.T) {
91
151
getDescriptorInput (t , DataGeneric , []byte {0xfa , 0xce }),
92
152
),
93
153
},
94
- id : 1 ,
154
+ ids : [] uint32 { 1 } ,
95
155
opts : []DeleteOpt {
96
156
OptDeleteWithTime (time .Unix (946702800 , 0 )),
97
157
},
@@ -106,7 +166,7 @@ func TestDeleteObject(t *testing.T) {
106
166
),
107
167
),
108
168
},
109
- id : 1 ,
169
+ ids : [] uint32 { 1 } ,
110
170
},
111
171
}
112
172
@@ -119,8 +179,10 @@ func TestDeleteObject(t *testing.T) {
119
179
t .Fatal (err )
120
180
}
121
181
122
- if got , want := f .DeleteObject (tt .id , tt .opts ... ), tt .wantErr ; ! errors .Is (got , want ) {
123
- t .Errorf ("got error %v, want %v" , got , want )
182
+ for _ , id := range tt .ids {
183
+ if got , want := f .DeleteObject (id , tt .opts ... ), tt .wantErr ; ! errors .Is (got , want ) {
184
+ t .Errorf ("got error %v, want %v" , got , want )
185
+ }
124
186
}
125
187
126
188
if err := f .UnloadContainer (); err != nil {
0 commit comments