github.com/artpar/rclone@v1.67.3/backend/s3/s3_test.go (about) 1 // Test S3 filesystem interface 2 package s3 3 4 import ( 5 "context" 6 "net/http" 7 "strings" 8 "testing" 9 10 "github.com/artpar/rclone/fs" 11 "github.com/artpar/rclone/fstest" 12 "github.com/artpar/rclone/fstest/fstests" 13 ) 14 15 func SetupS3Test(t *testing.T) (context.Context, *Options, *http.Client) { 16 ctx, opt := context.Background(), new(Options) 17 opt.Provider = "AWS" 18 client := getClient(ctx, opt) 19 return ctx, opt, client 20 } 21 22 // TestIntegration runs integration tests against the remote 23 func TestIntegration(t *testing.T) { 24 fstests.Run(t, &fstests.Opt{ 25 RemoteName: "TestS3:", 26 NilObject: (*Object)(nil), 27 TiersToTest: []string{"STANDARD", "STANDARD_IA"}, 28 ChunkedUpload: fstests.ChunkedUploadConfig{ 29 MinChunkSize: minChunkSize, 30 }, 31 }) 32 } 33 34 func TestIntegration2(t *testing.T) { 35 if *fstest.RemoteName != "" { 36 t.Skip("skipping as -remote is set") 37 } 38 name := "TestS3" 39 fstests.Run(t, &fstests.Opt{ 40 RemoteName: name + ":", 41 NilObject: (*Object)(nil), 42 TiersToTest: []string{"STANDARD", "STANDARD_IA"}, 43 ChunkedUpload: fstests.ChunkedUploadConfig{ 44 MinChunkSize: minChunkSize, 45 }, 46 ExtraConfig: []fstests.ExtraConfigItem{ 47 {Name: name, Key: "directory_markers", Value: "true"}, 48 }, 49 }) 50 } 51 52 func TestAWSDualStackOption(t *testing.T) { 53 { 54 // test enabled 55 ctx, opt, client := SetupS3Test(t) 56 opt.UseDualStack = true 57 s3Conn, _, _ := s3Connection(ctx, opt, client) 58 if !strings.Contains(s3Conn.Endpoint, "dualstack") { 59 t.Errorf("dualstack failed got: %s, wanted: dualstack", s3Conn.Endpoint) 60 t.Fail() 61 } 62 } 63 { 64 // test default case 65 ctx, opt, client := SetupS3Test(t) 66 s3Conn, _, _ := s3Connection(ctx, opt, client) 67 if strings.Contains(s3Conn.Endpoint, "dualstack") { 68 t.Errorf("dualstack failed got: %s, NOT wanted: dualstack", s3Conn.Endpoint) 69 t.Fail() 70 } 71 } 72 } 73 74 func (f *Fs) SetUploadChunkSize(cs fs.SizeSuffix) (fs.SizeSuffix, error) { 75 return f.setUploadChunkSize(cs) 76 } 77 78 func (f *Fs) SetUploadCutoff(cs fs.SizeSuffix) (fs.SizeSuffix, error) { 79 return f.setUploadCutoff(cs) 80 } 81 82 func (f *Fs) SetCopyCutoff(cs fs.SizeSuffix) (fs.SizeSuffix, error) { 83 return f.setCopyCutoff(cs) 84 } 85 86 var ( 87 _ fstests.SetUploadChunkSizer = (*Fs)(nil) 88 _ fstests.SetUploadCutoffer = (*Fs)(nil) 89 _ fstests.SetCopyCutoffer = (*Fs)(nil) 90 )