github.com/rclone/rclone@v1.66.1-0.20240517100346-7b89735ae726/backend/azureblob/azureblob_test.go (about) 1 // Test AzureBlob filesystem interface 2 3 //go:build !plan9 && !solaris && !js 4 5 package azureblob 6 7 import ( 8 "testing" 9 10 "github.com/rclone/rclone/fs" 11 "github.com/rclone/rclone/fstest" 12 "github.com/rclone/rclone/fstest/fstests" 13 "github.com/stretchr/testify/assert" 14 ) 15 16 // TestIntegration runs integration tests against the remote 17 func TestIntegration(t *testing.T) { 18 fstests.Run(t, &fstests.Opt{ 19 RemoteName: "TestAzureBlob:", 20 NilObject: (*Object)(nil), 21 TiersToTest: []string{"Hot", "Cool", "Cold"}, 22 ChunkedUpload: fstests.ChunkedUploadConfig{ 23 MinChunkSize: defaultChunkSize, 24 }, 25 }) 26 } 27 28 // TestIntegration2 runs integration tests against the remote 29 func TestIntegration2(t *testing.T) { 30 if *fstest.RemoteName != "" { 31 t.Skip("Skipping as -remote set") 32 } 33 name := "TestAzureBlob" 34 fstests.Run(t, &fstests.Opt{ 35 RemoteName: name + ":", 36 NilObject: (*Object)(nil), 37 TiersToTest: []string{"Hot", "Cool", "Cold"}, 38 ChunkedUpload: fstests.ChunkedUploadConfig{ 39 MinChunkSize: defaultChunkSize, 40 }, 41 ExtraConfig: []fstests.ExtraConfigItem{ 42 {Name: name, Key: "directory_markers", Value: "true"}, 43 }, 44 }) 45 } 46 47 func (f *Fs) SetUploadChunkSize(cs fs.SizeSuffix) (fs.SizeSuffix, error) { 48 return f.setUploadChunkSize(cs) 49 } 50 51 var ( 52 _ fstests.SetUploadChunkSizer = (*Fs)(nil) 53 ) 54 55 func TestValidateAccessTier(t *testing.T) { 56 tests := map[string]struct { 57 accessTier string 58 want bool 59 }{ 60 "hot": {"hot", true}, 61 "HOT": {"HOT", true}, 62 "Hot": {"Hot", true}, 63 "cool": {"cool", true}, 64 "cold": {"cold", true}, 65 "archive": {"archive", true}, 66 "empty": {"", false}, 67 "unknown": {"unknown", false}, 68 } 69 70 for name, test := range tests { 71 t.Run(name, func(t *testing.T) { 72 got := validateAccessTier(test.accessTier) 73 assert.Equal(t, test.want, got) 74 }) 75 } 76 }