@@ -7,13 +7,17 @@ import (
77 "io/fs"
88 "net/http"
99 "net/http/httptest"
10+ "strings"
1011 "testing"
1112
1213 "github.com/stretchr/testify/require"
1314 ctrl "sigs.k8s.io/controller-runtime"
1415)
1516
1617func TestStorageServerHandlerWrapped_Gzip (t * testing.T ) {
18+ var generatedJSON = func (size int ) string {
19+ return "{\" data\" :\" " + strings .Repeat ("test data " , size ) + "\" }"
20+ }
1721 tests := []struct {
1822 name string
1923 acceptEncoding string
@@ -24,7 +28,7 @@ func TestStorageServerHandlerWrapped_Gzip(t *testing.T) {
2428 {
2529 name : "compresses large response when client accepts gzip" ,
2630 acceptEncoding : "gzip" ,
27- responseContent : testCompressableJSON ,
31+ responseContent : generatedJSON ( 1000 ) ,
2832 expectCompressed : true ,
2933 expectedStatus : http .StatusOK ,
3034 },
@@ -38,7 +42,7 @@ func TestStorageServerHandlerWrapped_Gzip(t *testing.T) {
3842 {
3943 name : "does not compress when client doesn't accept gzip" ,
4044 acceptEncoding : "" ,
41- responseContent : testCompressableJSON ,
45+ responseContent : generatedJSON ( 1000 ) ,
4246 expectCompressed : false ,
4347 expectedStatus : http .StatusOK ,
4448 },
@@ -96,137 +100,6 @@ func TestStorageServerHandlerWrapped_Gzip(t *testing.T) {
96100 }
97101}
98102
99- const testCompressableJSON = `{
100- "defaultChannel": "stable-v6.x",
101- "name": "cockroachdb",
102- "schema": "olm.package"
103- }
104- {
105- "entries": [
106- {
107- "name": "cockroachdb.v5.0.3"
108- },
109- {
110- "name": "cockroachdb.v5.0.4",
111- "replaces": "cockroachdb.v5.0.3"
112- }
113- ],
114- "name": "stable-5.x",
115- "package": "cockroachdb",
116- "schema": "olm.channel"
117- }
118- {
119- "entries": [
120- {
121- "name": "cockroachdb.v6.0.0",
122- "skipRange": "<6.0.0"
123- }
124- ],
125- "name": "stable-v6.x",
126- "package": "cockroachdb",
127- "schema": "olm.channel"
128- }
129- {
130- "image": "quay.io/openshift-community-operators/cockroachdb@sha256:a5d4f4467250074216eb1ba1c36e06a3ab797d81c431427fc2aca97ecaf4e9d8",
131- "name": "cockroachdb.v5.0.3",
132- "package": "cockroachdb",
133- "properties": [
134- {
135- "type": "olm.gvk",
136- "value": {
137- "group": "charts.operatorhub.io",
138- "kind": "Cockroachdb",
139- "version": "v1alpha1"
140- }
141- },
142- {
143- "type": "olm.package",
144- "value": {
145- "packageName": "cockroachdb",
146- "version": "5.0.3"
147- }
148- }
149- ],
150- "relatedImages": [
151- {
152- "name": "",
153- "image": "quay.io/helmoperators/cockroachdb:v5.0.3"
154- },
155- {
156- "name": "",
157- "image": "quay.io/openshift-community-operators/cockroachdb@sha256:a5d4f4467250074216eb1ba1c36e06a3ab797d81c431427fc2aca97ecaf4e9d8"
158- }
159- ],
160- "schema": "olm.bundle"
161- }
162- {
163- "image": "quay.io/openshift-community-operators/cockroachdb@sha256:f42337e7b85a46d83c94694638e2312e10ca16a03542399a65ba783c94a32b63",
164- "name": "cockroachdb.v5.0.4",
165- "package": "cockroachdb",
166- "properties": [
167- {
168- "type": "olm.gvk",
169- "value": {
170- "group": "charts.operatorhub.io",
171- "kind": "Cockroachdb",
172- "version": "v1alpha1"
173- }
174- },
175- {
176- "type": "olm.package",
177- "value": {
178- "packageName": "cockroachdb",
179- "version": "5.0.4"
180- }
181- }
182- ],
183- "relatedImages": [
184- {
185- "name": "",
186- "image": "quay.io/helmoperators/cockroachdb:v5.0.4"
187- },
188- {
189- "name": "",
190- "image": "quay.io/openshift-community-operators/cockroachdb@sha256:f42337e7b85a46d83c94694638e2312e10ca16a03542399a65ba783c94a32b63"
191- }
192- ],
193- "schema": "olm.bundle"
194- }
195- {
196- "image": "quay.io/openshift-community-operators/cockroachdb@sha256:d3016b1507515fc7712f9c47fd9082baf9ccb070aaab58ed0ef6e5abdedde8ba",
197- "name": "cockroachdb.v6.0.0",
198- "package": "cockroachdb",
199- "properties": [
200- {
201- "type": "olm.gvk",
202- "value": {
203- "group": "charts.operatorhub.io",
204- "kind": "Cockroachdb",
205- "version": "v1alpha1"
206- }
207- },
208- {
209- "type": "olm.package",
210- "value": {
211- "packageName": "cockroachdb",
212- "version": "6.0.0"
213- }
214- }
215- ],
216- "relatedImages": [
217- {
218- "name": "",
219- "image": "quay.io/cockroachdb/cockroach-helm-operator:6.0.0"
220- },
221- {
222- "name": "",
223- "image": "quay.io/openshift-community-operators/cockroachdb@sha256:d3016b1507515fc7712f9c47fd9082baf9ccb070aaab58ed0ef6e5abdedde8ba"
224- }
225- ],
226- "schema": "olm.bundle"
227- }
228- `
229-
230103// mockStorageInstance implements storage.Instance interface for testing
231104type mockStorageInstance struct {
232105 content string
0 commit comments