github.com/t2y/goofys@v0.19.1-0.20190123053037-27053313e616/internal/minio_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  	"golang.org/x/net/context"
    21  
    22  	"github.com/aws/aws-sdk-go/aws"
    23  	"github.com/aws/aws-sdk-go/aws/credentials"
    24  	"github.com/aws/aws-sdk-go/aws/session"
    25  	"github.com/aws/aws-sdk-go/service/s3"
    26  )
    27  
    28  type MinioTest struct {
    29  	fs *Goofys
    30  }
    31  
    32  var _ = Suite(&MinioTest{})
    33  
    34  func (s *MinioTest) SetUpSuite(t *C) {
    35  	awsConfig := &aws.Config{
    36  		Credentials: credentials.NewStaticCredentials("Q3AM3UQ867SPQQA43P2F",
    37  			"zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", ""),
    38  		Region:           aws.String("us-east-1"),
    39  		Endpoint:         aws.String("https://play.minio.io:9000"),
    40  		S3ForcePathStyle: aws.Bool(true),
    41  	}
    42  
    43  	s.fs = &Goofys{
    44  		awsConfig: awsConfig,
    45  		sess:      session.New(awsConfig),
    46  	}
    47  
    48  	s.fs.s3 = s.fs.newS3()
    49  	_, err := s.fs.s3.ListBuckets(nil)
    50  	t.Assert(err, IsNil)
    51  }
    52  
    53  func (s *MinioTest) SetUpTest(t *C) {
    54  	bucket := RandStringBytesMaskImprSrc(32)
    55  
    56  	_, err := s.fs.s3.CreateBucket(&s3.CreateBucketInput{
    57  		Bucket: &bucket,
    58  	})
    59  	t.Assert(err, IsNil)
    60  
    61  	uid, gid := MyUserAndGroup()
    62  	flags := &FlagStorage{
    63  		StorageClass: "STANDARD",
    64  		DirMode:      0700,
    65  		FileMode:     0700,
    66  		Uid:          uint32(uid),
    67  		Gid:          uint32(gid),
    68  	}
    69  
    70  	s.fs = NewGoofys(context.Background(), bucket, s.fs.awsConfig, flags)
    71  	t.Assert(s.fs, NotNil)
    72  }
    73  
    74  func (s *MinioTest) TestNoop(t *C) {
    75  }