mirror of https://github.com/docker/cli.git
36 lines
852 B
Go
36 lines
852 B
Go
|
package engine
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/docker/cli/internal/containerizedengine"
|
||
|
"gotest.tools/assert"
|
||
|
)
|
||
|
|
||
|
func TestUpdateNoContainerd(t *testing.T) {
|
||
|
testCli.SetContainerizedEngineClient(
|
||
|
func(string) (containerizedengine.Client, error) {
|
||
|
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(
|
||
|
func(string) (containerizedengine.Client, error) {
|
||
|
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)
|
||
|
}
|