浏览代码

update delegation test to check all context types

Signed-off-by: aiordache <[email protected]>
aiordache 5 年之前
父节点
当前提交
5f7c284d58
共有 5 个文件被更改,包括 25 次插入29 次删除
  1. 0 19
      .vscode/launch.json
  2. 1 2
      aci/backend.go
  3. 1 1
      aci/context.go
  4. 4 4
      aci/resourcegroup.go
  5. 19 3
      cli/mobycli/exec_test.go

+ 0 - 19
.vscode/launch.json

@@ -1,19 +0,0 @@
-{
-    // Use IntelliSense to learn about possible attributes.
-    // Hover to view descriptions of existing attributes.
-    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
-    "version": "0.2.0",
-    "configurations": [
-        {
-            "name": "Launch",
-            "type": "go",
-            "request": "launch",
-            "mode": "auto",
-            "program": "${workspaceRoot}/cli/main.go",
-            "env": {},
-            "cwd": "${workspaceRoot}/test/",
-            //"args": ["context", "create", "aws", "ecs", --profile", "sandbox.devtools.developer", "--region", "eu-west-3", "--description", "My ECS account"]
-            "args":["compose", "up"]
-        }
-    ]
-}

+ 1 - 2
aci/backend.go

@@ -41,9 +41,8 @@ import (
 	"github.com/docker/api/errdefs"
 	"github.com/docker/api/errdefs"
 )
 )
 
 
-const backendType = store.AciContextType
-
 const (
 const (
+	backendType               = store.AciContextType
 	singleContainerTag        = "docker-single-container"
 	singleContainerTag        = "docker-single-container"
 	composeContainerTag       = "docker-compose-application"
 	composeContainerTag       = "docker-compose-application"
 	composeContainerSeparator = "_"
 	composeContainerSeparator = "_"

+ 1 - 1
aci/context.go

@@ -33,7 +33,7 @@ import (
 
 
 type contextCreateACIHelper struct {
 type contextCreateACIHelper struct {
 	selector            prompt.UI
 	selector            prompt.UI
-	resourceGroupHelper ACIResourceGroupHelper
+	resourceGroupHelper ResourceGroupHelper
 }
 }
 
 
 func newContextCreateHelper() contextCreateACIHelper {
 func newContextCreateHelper() contextCreateACIHelper {

+ 4 - 4
aci/resourcegroup.go

@@ -26,8 +26,8 @@ import (
 	"github.com/docker/api/errdefs"
 	"github.com/docker/api/errdefs"
 )
 )
 
 
-// ACIResourceGroupHelper interface to manage resource groups and subscription IDs
-type ACIResourceGroupHelper interface {
+// ResourceGroupHelper interface to manage resource groups and subscription IDs
+type ResourceGroupHelper interface {
 	GetSubscriptionIDs(ctx context.Context) ([]subscription.Model, error)
 	GetSubscriptionIDs(ctx context.Context) ([]subscription.Model, error)
 	ListGroups(ctx context.Context, subscriptionID string) ([]resources.Group, error)
 	ListGroups(ctx context.Context, subscriptionID string) ([]resources.Group, error)
 	GetGroup(ctx context.Context, subscriptionID string, groupName string) (resources.Group, error)
 	GetGroup(ctx context.Context, subscriptionID string, groupName string) (resources.Group, error)
@@ -38,8 +38,8 @@ type ACIResourceGroupHelper interface {
 type aciResourceGroupHelperImpl struct {
 type aciResourceGroupHelperImpl struct {
 }
 }
 
 
-// NewACIResourceGroupHelper create a new ACIResourceGroupHelper
-func NewACIResourceGroupHelper() ACIResourceGroupHelper {
+// NewACIResourceGroupHelper create a new ResourceGroupHelper
+func NewACIResourceGroupHelper() ResourceGroupHelper {
 	return aciResourceGroupHelperImpl{}
 	return aciResourceGroupHelperImpl{}
 }
 }
 
 

+ 19 - 3
cli/mobycli/exec_test.go

@@ -6,6 +6,7 @@ import (
 	. "github.com/onsi/gomega"
 	. "github.com/onsi/gomega"
 	"github.com/stretchr/testify/suite"
 	"github.com/stretchr/testify/suite"
 
 
+	"github.com/docker/api/context/store"
 	"github.com/docker/api/tests/framework"
 	"github.com/docker/api/tests/framework"
 )
 )
 
 
@@ -14,9 +15,24 @@ type MobyExecSuite struct {
 }
 }
 
 
 func (sut *MobyExecSuite) TestDelegateContextTypeToMoby() {
 func (sut *MobyExecSuite) TestDelegateContextTypeToMoby() {
-	Expect(mustDelegateToMoby("moby")).To(BeTrue())
-	Expect(mustDelegateToMoby("aws")).To(BeFalse())
-	Expect(mustDelegateToMoby("aci")).To(BeFalse())
+
+	isDelegated := func(val string) bool {
+		for _, ctx := range delegatedContextTypes {
+			if ctx == val {
+				return true
+			}
+		}
+		return false
+	}
+
+	allCtx := []string{store.AciContextType, store.EcsContextType, store.AwsContextType, store.DefaultContextType}
+	for _, ctx := range allCtx {
+		if isDelegated(ctx) {
+			Expect(mustDelegateToMoby(ctx)).To(BeTrue())
+			continue
+		}
+		Expect(mustDelegateToMoby(ctx)).To(BeFalse())
+	}
 }
 }
 
 
 func TestExec(t *testing.T) {
 func TestExec(t *testing.T) {