Skip to content

Commit

Permalink
Merge pull request openshift#9832 from csrwng/fix_newapp_int
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot authored Jul 14, 2016
2 parents 5d153b2 + c274ac4 commit 75b1e8d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 37 deletions.
29 changes: 7 additions & 22 deletions pkg/generate/app/dockerimagelookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,9 @@ import (
"testing"

docker "github.com/fsouza/go-dockerclient"
apptest "github.com/openshift/origin/pkg/generate/app/test"
)

type fakeDockerClient struct {
// list result
images []docker.APIImages
// inspect result
image *docker.Image
listErr error
inspectErr error
}

func (f fakeDockerClient) ListImages(opts docker.ListImagesOptions) ([]docker.APIImages, error) {
return f.images, f.listErr
}
func (f fakeDockerClient) InspectImage(name string) (*docker.Image, error) {
return f.image, f.inspectErr
}

type fakeRegistrySearcher struct {
matches ComponentMatches
errs []error
Expand Down Expand Up @@ -53,9 +38,9 @@ func TestDockerImageLookup(t *testing.T) {

// found in remote registry, local docker client defined
searcher := DockerClientSearcher{
Client: &fakeDockerClient{
images: images,
image: image,
Client: &apptest.FakeDockerClient{
Images: images,
Image: image,
},
RegistrySearcher: fakeRegistrySearcher{
matches: matches,
Expand Down Expand Up @@ -88,9 +73,9 @@ func TestDockerImageLookup(t *testing.T) {

// found in local docker client
searcher = DockerClientSearcher{
Client: &fakeDockerClient{
images: images,
image: image,
Client: &apptest.FakeDockerClient{
Images: images,
Image: image,
},
RegistrySearcher: fakeRegistrySearcher{
matches: ComponentMatches{},
Expand Down
21 changes: 21 additions & 0 deletions pkg/generate/app/test/fakedocker.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package test

import (
docker "github.com/fsouza/go-dockerclient"
)

type FakeDockerClient struct {
// list result
Images []docker.APIImages
// inspect result
Image *docker.Image
ListErr error
InspectErr error
}

func (f FakeDockerClient) ListImages(opts docker.ListImagesOptions) ([]docker.APIImages, error) {
return f.Images, f.ListErr
}
func (f FakeDockerClient) InspectImage(name string) (*docker.Image, error) {
return f.Image, f.InspectErr
}
23 changes: 8 additions & 15 deletions test/integration/newapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

package integration

/*
// FIXME: This test is disabled because kubernetes switched to engine-api which
// will require significant refactor.
import (
"bytes"
"fmt"
Expand All @@ -27,7 +22,6 @@ import (
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/unversioned"
ktestclient "k8s.io/kubernetes/pkg/client/unversioned/testclient"
"k8s.io/kubernetes/pkg/kubelet/dockertools"
"k8s.io/kubernetes/pkg/runtime"
utilerrs "k8s.io/kubernetes/pkg/util/errors"
"k8s.io/kubernetes/pkg/util/sets"
Expand All @@ -38,6 +32,7 @@ import (
"github.com/openshift/origin/pkg/dockerregistry"
"github.com/openshift/origin/pkg/generate/app"
"github.com/openshift/origin/pkg/generate/app/cmd"
apptest "github.com/openshift/origin/pkg/generate/app/test"
"github.com/openshift/origin/pkg/generate/dockerfile"
"github.com/openshift/origin/pkg/generate/source"
imageapi "github.com/openshift/origin/pkg/image/api"
Expand Down Expand Up @@ -471,7 +466,7 @@ func TestNewAppRunAll(t *testing.T) {

Resolvers: cmd.Resolvers{
DockerSearcher: app.DockerClientSearcher{
Client: &dockertools.FakeDockerClient{
Client: &apptest.FakeDockerClient{
Images: []docker.APIImages{{RepoTags: []string{"myrepo:5000/myco/example"}}},
Image: dockerBuilderImage(),
},
Expand Down Expand Up @@ -560,7 +555,7 @@ func TestNewAppRunAll(t *testing.T) {

Resolvers: cmd.Resolvers{
DockerSearcher: app.DockerClientSearcher{
Client: &dockertools.FakeDockerClient{
Client: &apptest.FakeDockerClient{
Images: []docker.APIImages{{RepoTags: []string{"centos/ruby-22-centos7"}}},
Image: dockerBuilderImage(),
},
Expand Down Expand Up @@ -605,7 +600,7 @@ func TestNewAppRunAll(t *testing.T) {

Resolvers: cmd.Resolvers{
DockerSearcher: app.DockerClientSearcher{
Client: &dockertools.FakeDockerClient{
Client: &apptest.FakeDockerClient{
Images: []docker.APIImages{{RepoTags: []string{"centos/ruby-22-centos7"}}},
Image: dockerBuilderImage(),
},
Expand Down Expand Up @@ -651,7 +646,7 @@ func TestNewAppRunAll(t *testing.T) {
},
Resolvers: cmd.Resolvers{
DockerSearcher: app.DockerClientSearcher{
Client: &dockertools.FakeDockerClient{
Client: &apptest.FakeDockerClient{
Images: []docker.APIImages{{RepoTags: []string{"mysql"}}},
Image: &docker.Image{
Config: &docker.Config{
Expand Down Expand Up @@ -773,7 +768,7 @@ func TestNewAppRunAll(t *testing.T) {
break
}
expectedPort, _ := strconv.Atoi(test.checkPort)
if tp.Spec.Ports[0].Port != expectedPort {
if tp.Spec.Ports[0].Port != int32(expectedPort) {
t.Errorf("%s: did not get expected port in service. Expected: %d. Got %d\n",
test.name, expectedPort, tp.Spec.Ports[0].Port)
}
Expand Down Expand Up @@ -1643,7 +1638,7 @@ func templateList() *templateapi.TemplateList {

func fakeDockerSearcher() app.Searcher {
return app.DockerClientSearcher{
Client: &dockertools.FakeDockerClient{
Client: &apptest.FakeDockerClient{
Images: []docker.APIImages{{RepoTags: []string{"library/ruby:latest"}}},
Image: dockerBuilderImage(),
},
Expand All @@ -1654,7 +1649,7 @@ func fakeDockerSearcher() app.Searcher {

func fakeSimpleDockerSearcher() app.Searcher {
return app.DockerClientSearcher{
Client: &dockertools.FakeDockerClient{
Client: &apptest.FakeDockerClient{
Images: []docker.APIImages{{RepoTags: []string{"centos/ruby-22-centos7"}}},
Image: &docker.Image{
ID: "ruby",
Expand Down Expand Up @@ -1719,5 +1714,3 @@ func PrepareAppConfig(config *cmd.AppConfig) (stdout, stderr *bytes.Buffer) {
config.Typer = kapi.Scheme
return
}
*/

0 comments on commit 75b1e8d

Please sign in to comment.