コード例 #1
0
import (
	"errors"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/cloudfoundry-incubator/ltc/docker_runner/docker_metadata_fetcher"
	"github.com/cloudfoundry-incubator/ltc/docker_runner/docker_metadata_fetcher/fake_docker_session"
	"github.com/docker/docker/registry"
)

var _ = Describe("DockerMetaDataFetcher", func() {
	var (
		fakeDockerSessionFactory *fake_docker_session.FakeDockerSessionFactory
		fakeDockerSession        *fake_docker_session.FakeDockerSession
		dockerMetadataFetcher    docker_metadata_fetcher.DockerMetadataFetcher
	)

	BeforeEach(func() {
		fakeDockerSession = &fake_docker_session.FakeDockerSession{}
		fakeDockerSessionFactory = &fake_docker_session.FakeDockerSessionFactory{}
		dockerMetadataFetcher = docker_metadata_fetcher.New(fakeDockerSessionFactory)
	})

	Describe("FetchMetadata", func() {

		Context("when fetching metadata from the docker hub registry", func() {
			It("returns the ImageMetadata with the WorkingDir, StartCommand, and PortConfig, and sets the monitored port to the lowest exposed tcp port", func() {
				fakeDockerSessionFactory.MakeSessionReturns(fakeDockerSession, nil)
				imageList := map[string]*registry.ImgData{