瀏覽代碼

Refactor placement and method name

Signed-off-by: Ulysses Souza <[email protected]>
Ulysses Souza 5 年之前
父節點
當前提交
bdd987f246
共有 4 個文件被更改,包括 8 次插入75 次删除
  1. 7 7
      azure/convert/volume.go
  2. 0 67
      azure/storage/storage_test.go
  3. 1 1
      tests/aci-e2e/e2e-aci.go
  4. 0 0
      tests/aci-e2e/storage/storage.go

+ 7 - 7
azure/convert/volume.go

@@ -49,7 +49,7 @@ type volumeInput struct {
 	target   string
 }
 
-func scapeKeySlashes(rawURL string) (string, error) {
+func escapeKeySlashes(rawURL string) (string, error) {
 	urlSplit := strings.Split(rawURL, "@")
 	if len(urlSplit) < 1 {
 		return "", errors.New("invalid url format " + rawURL)
@@ -60,13 +60,13 @@ func scapeKeySlashes(rawURL string) (string, error) {
 	return scaped, nil
 }
 
-func unscapeKey(passwd string) string {
-	return strings.ReplaceAll(passwd, "_", "/")
+func unescapeKey(key string) string {
+	return strings.ReplaceAll(key, "_", "/")
 }
 
 // Removes the second ':' that separates the source from target
 func volumeURL(pathURL string) (*url.URL, error) {
-	scapedURL, err := scapeKeySlashes(pathURL)
+	scapedURL, err := escapeKeySlashes(pathURL)
 	if err != nil {
 		return nil, err
 	}
@@ -92,11 +92,11 @@ func (v *volumeInput) parse(name string, s string) error {
 	if v.username == "" {
 		return fmt.Errorf("volume specification %q does not include a storage username", v)
 	}
-	passwd, ok := volumeURL.User.Password()
-	if !ok || passwd == "" {
+	key, ok := volumeURL.User.Password()
+	if !ok || key == "" {
 		return fmt.Errorf("volume specification %q does not include a storage key", v)
 	}
-	v.key = unscapeKey(passwd)
+	v.key = unescapeKey(key)
 	v.share = volumeURL.Host
 	if v.share == "" {
 		return fmt.Errorf("volume specification %q does not include a storage file share", v)

+ 0 - 67
azure/storage/storage_test.go

@@ -1,67 +0,0 @@
-package storage
-
-import (
-	"context"
-	"fmt"
-	"net/url"
-	"testing"
-
-	"github.com/Azure/azure-storage-file-go/azfile"
-	. "github.com/onsi/gomega"
-
-	"github.com/docker/api/azure"
-	"github.com/docker/api/context/store"
-)
-
-const (
-	resourceGroupName = "rgulyssessouza"
-	location          = "westeurope"
-
-	testAccountName = "dockertestaccountname"
-	testShareName   = "dockertestsharename"
-	testContent     = "test content!"
-)
-
-func TestGetContainerName(t *testing.T) {
-	RegisterTestingT(t)
-
-	subscriptionID, err := azure.GetSubscriptionID(context.TODO())
-	Expect(err).To(BeNil())
-	aciContext := store.AciContext{
-		SubscriptionID: subscriptionID,
-		Location:       location,
-		ResourceGroup:  resourceGroupName,
-	}
-
-	storageAccount, err := CreateStorageAccount(context.TODO(), aciContext, testAccountName)
-	Expect(err).To(BeNil())
-	Expect(*storageAccount.Name).To(Equal(testAccountName))
-
-	list, err := ListKeys(context.TODO(), aciContext, *storageAccount.Name)
-	Expect(err).To(BeNil())
-
-	firstKey := *(*list.Keys)[0].Value
-
-	// Create a ShareURL object that wraps a soon-to-be-created share's URL and a default pipeline.
-	u, _ := url.Parse(fmt.Sprintf("https://%s.file.core.windows.net/%s", testAccountName, testShareName))
-	credential, err := azfile.NewSharedKeyCredential(testAccountName, firstKey)
-	Expect(err).To(BeNil())
-
-	shareURL := azfile.NewShareURL(*u, azfile.NewPipeline(credential, azfile.PipelineOptions{}))
-	_, err = shareURL.Create(context.TODO(), azfile.Metadata{}, 0)
-	Expect(err).To(BeNil())
-
-	fURL, err := url.Parse(u.String() + "/testfile")
-	Expect(err).To(BeNil())
-	fileURL := azfile.NewFileURL(*fURL, azfile.NewPipeline(credential, azfile.PipelineOptions{}))
-	err = azfile.UploadBufferToAzureFile(context.TODO(), []byte(testContent), fileURL, azfile.UploadToAzureFileOptions{})
-	Expect(err).To(BeNil())
-
-	b := make([]byte, len(testContent))
-	_, err = azfile.DownloadAzureFileToBuffer(context.TODO(), fileURL, b, azfile.DownloadFromAzureFileOptions{})
-	Expect(err).To(BeNil())
-	Expect(string(b)).To(Equal(testContent))
-
-	_, err = DeleteStorageAccount(context.TODO(), aciContext, testAccountName)
-	Expect(err).To(BeNil())
-}

+ 1 - 1
tests/aci-e2e/e2e-aci.go

@@ -16,8 +16,8 @@ import (
 	. "github.com/onsi/gomega"
 
 	"github.com/docker/api/azure"
-	"github.com/docker/api/azure/storage"
 	"github.com/docker/api/context/store"
+	"github.com/docker/api/tests/aci-e2e/storage"
 	. "github.com/docker/api/tests/framework"
 )
 

+ 0 - 0
azure/storage/storage.go → tests/aci-e2e/storage/storage.go