MCPcopy
hub / github.com/minio/minio-go / TestDefaultBucketLocation

Function TestDefaultBucketLocation

utils_test.go:216–266  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

214}
215
216func TestDefaultBucketLocation(t *testing.T) {
217 testCases := []struct {
218 endpointURL url.URL
219 regionOverride string
220 expectedLocation string
221 }{
222 // Region override is set URL is ignored. - Test 1.
223 {
224 endpointURL: url.URL{Host: "s3-fips-us-gov-west-1.amazonaws.com"},
225 regionOverride: "us-west-1",
226 expectedLocation: "us-west-1",
227 },
228 // No region override, url based preferenced is honored - Test 2.
229 {
230 endpointURL: url.URL{Host: "s3-fips-us-gov-west-1.amazonaws.com"},
231 regionOverride: "",
232 expectedLocation: "us-gov-west-1",
233 },
234 // Region override is honored - Test 3.
235 {
236 endpointURL: url.URL{Host: "s3.amazonaws.com"},
237 regionOverride: "us-west-1",
238 expectedLocation: "us-west-1",
239 },
240 // China region should be honored, region override not provided. - Test 4.
241 {
242 endpointURL: url.URL{Host: "s3.cn-north-1.amazonaws.com.cn"},
243 regionOverride: "",
244 expectedLocation: "cn-north-1",
245 },
246 // China region should be honored, region override not provided. - Test 5.
247 {
248 endpointURL: url.URL{Host: "s3.cn-northwest-1.amazonaws.com.cn"},
249 regionOverride: "",
250 expectedLocation: "cn-northwest-1",
251 },
252 // No region provided, no standard region strings provided as well. - Test 6.
253 {
254 endpointURL: url.URL{Host: "s3.amazonaws.com"},
255 regionOverride: "",
256 expectedLocation: "us-east-1",
257 },
258 }
259
260 for i, testCase := range testCases {
261 retLocation := getDefaultLocation(testCase.endpointURL, testCase.regionOverride)
262 if testCase.expectedLocation != retLocation {
263 t.Errorf("Test %d: Expected location %s, got %s", i+1, testCase.expectedLocation, retLocation)
264 }
265 }
266}
267
268// Tests validate the expiry time validator.
269func TestIsValidExpiry(t *testing.T) {

Callers

nothing calls this directly

Calls 1

getDefaultLocationFunction · 0.85

Tested by

no test coverage detected