Skip to content

Commit 90d84f3

Browse files
committed
migrate e2e container rename test
Signed-off-by: carsontham <carsontham@outlook.com>
1 parent 2f87a11 commit 90d84f3

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

e2e/container/rename_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package container
2+
3+
import (
4+
"strings"
5+
"testing"
6+
7+
"github.com/docker/cli/e2e/internal/fixtures"
8+
"gotest.tools/v3/assert"
9+
"gotest.tools/v3/icmd"
10+
)
11+
12+
func TestContainerRename(t *testing.T) {
13+
oldName := "old_name_" + t.Name()
14+
result := icmd.RunCommand("docker", "run", "-d", "--name", oldName, fixtures.AlpineImage, "sleep", "60")
15+
result.Assert(t, icmd.Success)
16+
containerID := strings.TrimSpace(result.Stdout())
17+
18+
newName := "new_name_" + t.Name()
19+
renameResult := icmd.RunCommand("docker", "container", "rename", oldName, newName)
20+
renameResult.Assert(t, icmd.Success)
21+
22+
inspectResult := icmd.RunCommand("docker", "inspect", "--format", "{{.Name}}", containerID)
23+
inspectResult.Assert(t, icmd.Success)
24+
assert.Equal(t, "/"+newName, strings.TrimSpace(inspectResult.Stdout()))
25+
}

0 commit comments

Comments
 (0)