github.com/del680202/goofys@v0.19.1-0.20180727070818-6a609fafa266/internal/aws_test.go (about) 1 // Copyright 2016 Ka-Hing Cheung 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package internal 16 17 import ( 18 . "gopkg.in/check.v1" 19 20 "github.com/aws/aws-sdk-go/aws" 21 "github.com/aws/aws-sdk-go/aws/session" 22 23 "github.com/jacobsa/fuse" 24 ) 25 26 type AwsTest struct { 27 fs *Goofys 28 } 29 30 var _ = Suite(&AwsTest{}) 31 32 func (s *AwsTest) SetUpSuite(t *C) { 33 awsConfig := &aws.Config{ 34 Region: aws.String("us-east-1"), 35 S3ForcePathStyle: aws.Bool(true), 36 } 37 38 s.fs = &Goofys{ 39 awsConfig: awsConfig, 40 sess: session.New(awsConfig), 41 } 42 43 s.fs.s3 = s.fs.newS3() 44 } 45 46 func (s *AwsTest) TestRegionDetection(t *C) { 47 s.fs.bucket = "goofys-eu-west-1.kahing.xyz" 48 49 err, isAws := s.fs.detectBucketLocationByHEAD() 50 t.Assert(err, IsNil) 51 t.Assert(*s.fs.awsConfig.Region, Equals, "eu-west-1") 52 t.Assert(isAws, Equals, true) 53 } 54 55 func (s *AwsTest) TestBucket404(t *C) { 56 s.fs.bucket = RandStringBytesMaskImprSrc(64) 57 58 err, isAws := s.fs.detectBucketLocationByHEAD() 59 t.Assert(err, Equals, fuse.ENOENT) 60 t.Assert(isAws, Equals, true) 61 }