Updating unit tests for updated engine-api

Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
This commit is contained in:
Nishant Totla 2016-05-25 16:03:57 -07:00
parent 82f1bfe0ec
commit 46ba8763be
No known key found for this signature in database
GPG Key ID: 7EA5781C9B3D0C19
3 changed files with 12 additions and 9 deletions

View File

@ -959,10 +959,14 @@ func (e *Engine) CreateVolume(request *types.VolumeCreateRequest) (*Volume, erro
// Pull an image on the engine
func (e *Engine) Pull(image string, authConfig *types.AuthConfig) error {
// TODO(nishanttotla): RegistryAuth probably needs fixing
// TODO(nishanttotla): RegistryAuth needs fixing
registryAuth := ""
if authConfig != nil {
registryAuth = authConfig.Auth
}
pullOpts := types.ImagePullOptions{
All: false,
RegistryAuth: authConfig.Auth,
RegistryAuth: registryAuth,
PrivilegeFunc: nil,
}
// image is a ref here
@ -1256,7 +1260,6 @@ func (e *Engine) RenameContainer(container *Container, newName string) error {
// BuildImage builds an image
func (e *Engine) BuildImage(buildContext io.Reader, buildImage *types.ImageBuildOptions) (io.ReadCloser, error) {
// TODO(nishanttotla): buildcontext for image could be specific instead of nil
resp, err := e.apiClient.ImageBuild(context.Background(), buildContext, *buildImage)
e.CheckConnectionErr(err)
if err != nil {

View File

@ -353,8 +353,8 @@ func TestCreateContainer(t *testing.T) {
id = "id3"
apiClient.On("ImageList", mock.Anything, mock.AnythingOfType("ImageListOptions")).Return([]types.Image{}, nil).Once()
mockConfig.HostConfig.CPUShares = int64(math.Ceil(float64(config.HostConfig.CPUShares*1024) / float64(mockInfo.NCPU)))
apiClient.On("ImagePull", mock.Anything, types.ImagePullOptions{ImageID: config.Image, Tag: "latest"}, mock.Anything).Return(readCloser, nil).Once()
// FIXMEENGINEAPI : below should return an engine-api error, or something custom
apiClient.On("ImagePull", mock.Anything, config.Image, mock.AnythingOfType("types.ImagePullOptions")).Return(readCloser, nil).Once()
// TODO(nishanttotla): below should return an engine-api error, or something custom, so that we can get rid of dockerclient
apiClient.On("ContainerCreate", mock.Anything, &mockConfig.Config, &mockConfig.HostConfig, &mockConfig.NetworkingConfig, name).Return(types.ContainerCreateResponse{}, dockerclient.ErrImageNotFound).Once()
// FIXMEENGINEAPI : below should return an engine-api error, or something custom
apiClient.On("ContainerCreate", mock.Anything, &mockConfig.Config, &mockConfig.HostConfig, &mockConfig.NetworkingConfig, name).Return(types.ContainerCreateResponse{ID: id}, nil).Once()
@ -531,7 +531,7 @@ func TestRemoveImage(t *testing.T) {
apiClient := engineapimock.NewMockClient()
apiClient.On("ImageList", mock.Anything, mock.AnythingOfType("ImageListOptions")).Return([]types.Image{}, nil)
apiClient.On("ImageRemove", mock.Anything,
apiClient.On("ImageRemove", mock.Anything, mock.Anything,
mock.AnythingOfType("ImageRemoveOptions")).Return(dIs, nil)
engine.apiClient = apiClient

View File

@ -155,7 +155,7 @@ func TestImportImage(t *testing.T) {
// import success
readCloser := nopCloser{bytes.NewBufferString("ok")}
apiClient.On("ImageImport", mock.Anything, mock.AnythingOfType("types.ImageImportOptions")).Return(readCloser, nil).Once()
apiClient.On("ImageImport", mock.Anything, mock.AnythingOfType("types.ImageImportSource"), mock.Anything, mock.AnythingOfType("types.ImageImportOptions")).Return(readCloser, nil).Once()
callback := func(what, status string, err error) {
// import success
@ -166,7 +166,7 @@ func TestImportImage(t *testing.T) {
// import error
readCloser = nopCloser{bytes.NewBufferString("error")}
err := fmt.Errorf("Import error")
apiClient.On("ImageImport", mock.Anything, mock.AnythingOfType("types.ImageImportOptions")).Return(readCloser, err).Once()
apiClient.On("ImageImport", mock.Anything, mock.AnythingOfType("types.ImageImportSource"), mock.Anything, mock.AnythingOfType("types.ImageImportOptions")).Return(readCloser, err).Once()
callback = func(what, status string, err error) {
// import error
@ -264,7 +264,7 @@ func TestTagImage(t *testing.T) {
c.engines[engine.ID] = engine
// tag image
apiClient.On("ImageTag", mock.Anything, mock.AnythingOfType("types.ImageTagOptions")).Return(nil).Once()
apiClient.On("ImageTag", mock.Anything, mock.Anything, mock.Anything, mock.AnythingOfType("types.ImageTagOptions")).Return(nil).Once()
assert.Nil(t, c.TagImage("busybox", "test_busybox", "latest", false))
assert.NotNil(t, c.TagImage("busybox_not_exists", "test_busybox", "latest", false))
}