Refactor pkg/common, Fixes #11599
Signed-off-by: Antonio Murdaca <me@runcom.ninja> Upstream-commit: b80fae735684406d848b16a0f148a746e17ed25f Component: engine
This commit is contained in:
@ -12,7 +12,7 @@ import (
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/api/client"
|
||||
"github.com/docker/docker/daemon"
|
||||
"github.com/docker/docker/pkg/common"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
"github.com/docker/docker/pkg/term"
|
||||
"github.com/kr/pty"
|
||||
)
|
||||
@ -286,7 +286,7 @@ func TestAttachDetachTruncatedID(t *testing.T) {
|
||||
ch := make(chan struct{})
|
||||
go func() {
|
||||
defer close(ch)
|
||||
if err := cli.CmdAttach(common.TruncateID(container.ID)); err != nil {
|
||||
if err := cli.CmdAttach(stringid.TruncateID(container.ID)); err != nil {
|
||||
if err != io.ErrClosedPipe {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@ -2,19 +2,20 @@ package docker
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/docker/docker/autogen/dockerversion"
|
||||
"github.com/docker/docker/daemon/graphdriver"
|
||||
"github.com/docker/docker/graph"
|
||||
"github.com/docker/docker/image"
|
||||
"github.com/docker/docker/pkg/archive"
|
||||
"github.com/docker/docker/pkg/common"
|
||||
"github.com/docker/docker/utils"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/autogen/dockerversion"
|
||||
"github.com/docker/docker/daemon/graphdriver"
|
||||
"github.com/docker/docker/graph"
|
||||
"github.com/docker/docker/image"
|
||||
"github.com/docker/docker/pkg/archive"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
"github.com/docker/docker/utils"
|
||||
)
|
||||
|
||||
func TestMount(t *testing.T) {
|
||||
@ -70,7 +71,7 @@ func TestInterruptedRegister(t *testing.T) {
|
||||
defer nukeGraph(graph)
|
||||
badArchive, w := io.Pipe() // Use a pipe reader as a fake archive which never yields data
|
||||
image := &image.Image{
|
||||
ID: common.GenerateRandomID(),
|
||||
ID: stringid.GenerateRandomID(),
|
||||
Comment: "testing",
|
||||
Created: time.Now(),
|
||||
}
|
||||
@ -130,7 +131,7 @@ func TestRegister(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
image := &image.Image{
|
||||
ID: common.GenerateRandomID(),
|
||||
ID: stringid.GenerateRandomID(),
|
||||
Comment: "testing",
|
||||
Created: time.Now(),
|
||||
}
|
||||
@ -160,7 +161,7 @@ func TestDeletePrefix(t *testing.T) {
|
||||
graph, _ := tempGraph(t)
|
||||
defer nukeGraph(graph)
|
||||
img := createTestImage(graph, t)
|
||||
if err := graph.Delete(common.TruncateID(img.ID)); err != nil {
|
||||
if err := graph.Delete(stringid.TruncateID(img.ID)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assertNImages(graph, t, 0)
|
||||
@ -246,19 +247,19 @@ func TestByParent(t *testing.T) {
|
||||
graph, _ := tempGraph(t)
|
||||
defer nukeGraph(graph)
|
||||
parentImage := &image.Image{
|
||||
ID: common.GenerateRandomID(),
|
||||
ID: stringid.GenerateRandomID(),
|
||||
Comment: "parent",
|
||||
Created: time.Now(),
|
||||
Parent: "",
|
||||
}
|
||||
childImage1 := &image.Image{
|
||||
ID: common.GenerateRandomID(),
|
||||
ID: stringid.GenerateRandomID(),
|
||||
Comment: "child1",
|
||||
Created: time.Now(),
|
||||
Parent: parentImage.ID,
|
||||
}
|
||||
childImage2 := &image.Image{
|
||||
ID: common.GenerateRandomID(),
|
||||
ID: stringid.GenerateRandomID(),
|
||||
Comment: "child2",
|
||||
Created: time.Now(),
|
||||
Parent: parentImage.ID,
|
||||
|
||||
@ -22,9 +22,9 @@ import (
|
||||
"github.com/docker/docker/engine"
|
||||
"github.com/docker/docker/image"
|
||||
"github.com/docker/docker/nat"
|
||||
"github.com/docker/docker/pkg/common"
|
||||
"github.com/docker/docker/pkg/ioutils"
|
||||
"github.com/docker/docker/pkg/reexec"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
"github.com/docker/docker/runconfig"
|
||||
"github.com/docker/docker/utils"
|
||||
)
|
||||
@ -306,7 +306,7 @@ func TestDaemonCreate(t *testing.T) {
|
||||
&runconfig.HostConfig{},
|
||||
"conflictname",
|
||||
)
|
||||
if _, _, err := daemon.Create(&runconfig.Config{Image: GetTestImage(daemon).ID, Cmd: []string{"ls", "-al"}}, &runconfig.HostConfig{}, testContainer.Name); err == nil || !strings.Contains(err.Error(), common.TruncateID(testContainer.ID)) {
|
||||
if _, _, err := daemon.Create(&runconfig.Config{Image: GetTestImage(daemon).ID, Cmd: []string{"ls", "-al"}}, &runconfig.HostConfig{}, testContainer.Name); err == nil || !strings.Contains(err.Error(), stringid.TruncateID(testContainer.ID)) {
|
||||
t.Fatalf("Name conflict error doesn't include the correct short id. Message was: %v", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user