2018-03-19 18:56:51 -04:00
|
|
|
package engine
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
2018-09-11 08:46:30 -04:00
|
|
|
clitypes "github.com/docker/cli/types"
|
2018-03-19 18:56:51 -04:00
|
|
|
"gotest.tools/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestUpdateNoContainerd(t *testing.T) {
|
|
|
|
testCli.SetContainerizedEngineClient(
|
2018-09-11 08:46:30 -04:00
|
|
|
func(string) (clitypes.ContainerizedClient, error) {
|
2018-03-19 18:56:51 -04:00
|
|
|
return nil, fmt.Errorf("some error")
|
|
|
|
},
|
|
|
|
)
|
|
|
|
cmd := newUpdateCommand(testCli)
|
|
|
|
cmd.SilenceUsage = true
|
|
|
|
cmd.SilenceErrors = true
|
|
|
|
err := cmd.Execute()
|
|
|
|
assert.ErrorContains(t, err, "unable to access local containerd")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestUpdateHappy(t *testing.T) {
|
|
|
|
testCli.SetContainerizedEngineClient(
|
2018-09-11 08:46:30 -04:00
|
|
|
func(string) (clitypes.ContainerizedClient, error) {
|
2018-03-19 18:56:51 -04:00
|
|
|
return &fakeContainerizedEngineClient{}, nil
|
|
|
|
},
|
|
|
|
)
|
|
|
|
cmd := newUpdateCommand(testCli)
|
|
|
|
cmd.Flags().Set("registry-prefix", "docker.io/docker")
|
|
|
|
cmd.Flags().Set("version", "someversion")
|
|
|
|
err := cmd.Execute()
|
|
|
|
assert.NilError(t, err)
|
|
|
|
}
|