update delegation test to check all context types

Signed-off-by: aiordache <anca.iordache@docker.com>
This commit is contained in:
aiordache 2020-07-29 16:05:13 +02:00
parent 87245ef727
commit 5f7c284d58
5 changed files with 25 additions and 29 deletions

19
.vscode/launch.json vendored
View File

@ -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"]
}
]
}

View File

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

View File

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

View File

@ -26,8 +26,8 @@ import (
"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)
ListGroups(ctx context.Context, subscriptionID 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 {
}
// NewACIResourceGroupHelper create a new ACIResourceGroupHelper
func NewACIResourceGroupHelper() ACIResourceGroupHelper {
// NewACIResourceGroupHelper create a new ResourceGroupHelper
func NewACIResourceGroupHelper() ResourceGroupHelper {
return aciResourceGroupHelperImpl{}
}

View File

@ -6,6 +6,7 @@ import (
. "github.com/onsi/gomega"
"github.com/stretchr/testify/suite"
"github.com/docker/api/context/store"
"github.com/docker/api/tests/framework"
)
@ -14,9 +15,24 @@ type MobyExecSuite struct {
}
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) {