2019-05-16 10:06:27 -04:00
|
|
|
package kubernetes
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/docker/cli/cli/command"
|
|
|
|
"github.com/docker/cli/cli/config/configfile"
|
|
|
|
cliflags "github.com/docker/cli/cli/flags"
|
2020-02-22 12:12:14 -05:00
|
|
|
"gotest.tools/v3/assert"
|
|
|
|
"gotest.tools/v3/env"
|
2019-05-16 10:06:27 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestDefaultContextInitializer(t *testing.T) {
|
|
|
|
cli, err := command.NewDockerCli()
|
|
|
|
assert.NilError(t, err)
|
|
|
|
defer env.Patch(t, "KUBECONFIG", "./testdata/test-kubeconfig")()
|
|
|
|
configFile := &configfile.ConfigFile{
|
|
|
|
StackOrchestrator: "all",
|
|
|
|
}
|
|
|
|
ctx, err := command.ResolveDefaultContext(&cliflags.CommonOptions{}, configFile, command.DefaultContextStoreConfig(), cli.Err())
|
|
|
|
assert.NilError(t, err)
|
|
|
|
assert.Equal(t, "default", ctx.Meta.Name)
|
|
|
|
assert.Equal(t, command.OrchestratorAll, ctx.Meta.Metadata.(command.DockerContext).StackOrchestrator)
|
|
|
|
assert.DeepEqual(t, "zoinx", ctx.Meta.Endpoints[KubernetesEndpoint].(EndpointMeta).DefaultNamespace)
|
|
|
|
}
|