Adapt the CLI to the host install model for 18.09.
Signed-off-by: Daniel Hiltgen <daniel.hiltgen@docker.com>
(cherry picked from commit 342afe44fb)
Signed-off-by: Daniel Hiltgen <daniel.hiltgen@docker.com>
40 lines
998 B
Go
40 lines
998 B
Go
package engine
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/docker/cli/types"
|
|
"gotest.tools/assert"
|
|
)
|
|
|
|
func TestActivateNoContainerd(t *testing.T) {
|
|
testCli.SetContainerizedEngineClient(
|
|
func(string) (types.ContainerizedClient, error) {
|
|
return nil, fmt.Errorf("some error")
|
|
},
|
|
)
|
|
isRoot = func() bool { return true }
|
|
cmd := newActivateCommand(testCli)
|
|
cmd.Flags().Set("license", "invalidpath")
|
|
cmd.SilenceUsage = true
|
|
cmd.SilenceErrors = true
|
|
err := cmd.Execute()
|
|
assert.ErrorContains(t, err, "unable to access local containerd")
|
|
}
|
|
|
|
func TestActivateBadLicense(t *testing.T) {
|
|
testCli.SetContainerizedEngineClient(
|
|
func(string) (types.ContainerizedClient, error) {
|
|
return &fakeContainerizedEngineClient{}, nil
|
|
},
|
|
)
|
|
isRoot = func() bool { return true }
|
|
cmd := newActivateCommand(testCli)
|
|
cmd.SilenceUsage = true
|
|
cmd.SilenceErrors = true
|
|
cmd.Flags().Set("license", "invalidpath")
|
|
err := cmd.Execute()
|
|
assert.Error(t, err, "open invalidpath: no such file or directory")
|
|
}
|