mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-02 03:08:15 +00:00
Various fixes for the fake docker client
* Properly return ImageNotFoundError * Support inject "Images" or "ImageInspects" and keep both in sync. * Remove the FakeDockerPuller and let FakeDockerClient subsumes its functinality. This reduces the overhead to maintain both objects. * Various small fixes and refactoring of the testing utils.
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
dockertypes "github.com/docker/engine-api/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -102,14 +103,15 @@ func TestContainerStatus(t *testing.T) {
|
||||
sConfig := makeSandboxConfig("foo", "bar", "1", 0)
|
||||
labels := map[string]string{"abc.xyz": "foo"}
|
||||
annotations := map[string]string{"foo.bar.baz": "abc"}
|
||||
config := makeContainerConfig(sConfig, "pause", "iamimage", 0, labels, annotations)
|
||||
imageName := "iamimage"
|
||||
config := makeContainerConfig(sConfig, "pause", imageName, 0, labels, annotations)
|
||||
|
||||
var defaultTime time.Time
|
||||
dt := defaultTime.UnixNano()
|
||||
ct, st, ft := dt, dt, dt
|
||||
state := runtimeapi.ContainerState_CONTAINER_CREATED
|
||||
imageRef := DockerImageIDPrefix + imageName
|
||||
// The following variables are not set in FakeDockerClient.
|
||||
imageRef := DockerImageIDPrefix + ""
|
||||
exitCode := int32(0)
|
||||
var reason, message string
|
||||
|
||||
@@ -129,11 +131,14 @@ func TestContainerStatus(t *testing.T) {
|
||||
Annotations: config.Annotations,
|
||||
}
|
||||
|
||||
fDocker.InjectImages([]dockertypes.Image{{ID: imageName}})
|
||||
|
||||
// Create the container.
|
||||
fClock.SetTime(time.Now().Add(-1 * time.Hour))
|
||||
expected.CreatedAt = fClock.Now().UnixNano()
|
||||
const sandboxId = "sandboxid"
|
||||
id, err := ds.CreateContainer(sandboxId, config, sConfig)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Check internal labels
|
||||
c, err := fDocker.InspectContainer(id)
|
||||
|
||||
Reference in New Issue
Block a user