storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/cmd/gateway-common_test.go (about) 1 /* 2 * MinIO Cloud Storage, (C) 2018 MinIO, Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package cmd 17 18 import ( 19 "reflect" 20 "testing" 21 ) 22 23 // Tests cache exclude parsing. 24 func TestParseGatewaySSE(t *testing.T) { 25 testCases := []struct { 26 gwSSEStr string 27 expected gatewaySSE 28 success bool 29 }{ 30 // valid input 31 {"c;S3", []string{"C", "S3"}, true}, 32 {"S3", []string{"S3"}, true}, 33 {"c,S3", []string{}, false}, 34 {"c;S3;KMS", []string{}, false}, 35 {"C;s3", []string{"C", "S3"}, true}, 36 } 37 38 for i, testCase := range testCases { 39 gwSSE, err := parseGatewaySSE(testCase.gwSSEStr) 40 if err != nil && testCase.success { 41 t.Errorf("Test %d: Expected success but failed instead %s", i+1, err) 42 } 43 if err == nil && !testCase.success { 44 t.Errorf("Test %d: Expected failure but passed instead", i+1) 45 } 46 if err == nil { 47 if !reflect.DeepEqual(gwSSE, testCase.expected) { 48 t.Errorf("Test %d: Expected %v, got %v", i+1, testCase.expected, gwSSE) 49 } 50 } 51 } 52 }