github.com/rclone/rclone@v1.66.1-0.20240517100346-7b89735ae726/backend/azurefiles/azurefiles_internal_test.go (about)

     1  //go:build !plan9 && !js
     2  
     3  package azurefiles
     4  
     5  import (
     6  	"context"
     7  	"math/rand"
     8  	"strings"
     9  	"testing"
    10  
    11  	"github.com/rclone/rclone/fstest/fstests"
    12  	"github.com/stretchr/testify/assert"
    13  )
    14  
    15  func (f *Fs) InternalTest(t *testing.T) {
    16  	t.Run("Authentication", f.InternalTestAuth)
    17  }
    18  
    19  var _ fstests.InternalTester = (*Fs)(nil)
    20  
    21  func (f *Fs) InternalTestAuth(t *testing.T) {
    22  	t.Skip("skipping since this requires authentication credentials which are not part of repo")
    23  	shareName := "test-rclone-oct-2023"
    24  	testCases := []struct {
    25  		name    string
    26  		options *Options
    27  	}{
    28  		{
    29  			name: "ConnectionString",
    30  			options: &Options{
    31  				ShareName:        shareName,
    32  				ConnectionString: "",
    33  			},
    34  		},
    35  		{
    36  			name: "AccountAndKey",
    37  			options: &Options{
    38  				ShareName: shareName,
    39  				Account:   "",
    40  				Key:       "",
    41  			}},
    42  		{
    43  			name: "SASUrl",
    44  			options: &Options{
    45  				ShareName: shareName,
    46  				SASURL:    "",
    47  			}},
    48  	}
    49  
    50  	for _, tc := range testCases {
    51  		t.Run(tc.name, func(t *testing.T) {
    52  			fs, err := newFsFromOptions(context.TODO(), "TestAzureFiles", "", tc.options)
    53  			assert.NoError(t, err)
    54  			dirName := randomString(10)
    55  			assert.NoError(t, fs.Mkdir(context.TODO(), dirName))
    56  		})
    57  	}
    58  }
    59  
    60  const chars = "abcdefghijklmnopqrstuvwzyxABCDEFGHIJKLMNOPQRSTUVWZYX"
    61  
    62  func randomString(charCount int) string {
    63  	strBldr := strings.Builder{}
    64  	for i := 0; i < charCount; i++ {
    65  		randPos := rand.Int63n(52)
    66  		strBldr.WriteByte(chars[randPos])
    67  	}
    68  	return strBldr.String()
    69  }