gconn "github.com/cloudfoundry-incubator/garden/client/connection"
	fconn "github.com/cloudfoundry-incubator/garden/client/connection/fakes"
	gfakes "github.com/cloudfoundry-incubator/garden/fakes"
	"github.com/concourse/atc/worker"
	"github.com/concourse/atc/worker/fakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
	"github.com/pivotal-golang/lager/lagertest"
)

var _ = Describe("Retryable", func() {
	var (
		innerConnection *fconn.FakeConnection
		retryPolicy     *fakes.FakeRetryPolicy
		sleeper         *fakes.FakeSleeper

		conn gconn.Connection
	)

	BeforeEach(func() {
		innerConnection = new(fconn.FakeConnection)
		retryPolicy = new(fakes.FakeRetryPolicy)
		sleeper = new(fakes.FakeSleeper)

		conn = worker.RetryableConnection{
			Connection:  innerConnection,
			Logger:      lagertest.NewTestLogger("retryable-connection"),
			Sleeper:     sleeper,
			RetryPolicy: retryPolicy,
		}
	gconn "github.com/cloudfoundry-incubator/garden/client/connection"
	fconn "github.com/cloudfoundry-incubator/garden/client/connection/fakes"
	gfakes "github.com/cloudfoundry-incubator/garden/fakes"
	"github.com/concourse/atc/worker"
	"github.com/concourse/atc/worker/fakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
	"github.com/pivotal-golang/lager/lagertest"
)

var _ = Describe("Retryable", func() {
	var (
		innerConnection   *fconn.FakeConnection
		retryPolicy       *fakes.FakeRetryPolicy
		sleeper           *fakes.FakeSleeper
		connectionFactory *fakes.FakeGardenConnectionFactory

		conn gconn.Connection
	)

	BeforeEach(func() {
		innerConnection = new(fconn.FakeConnection)
		retryPolicy = new(fakes.FakeRetryPolicy)
		sleeper = new(fakes.FakeSleeper)
		connectionFactory = new(fakes.FakeGardenConnectionFactory)
		connectionFactory.BuildConnectionReturns(innerConnection)
		connectionFactory.BuildConnectionFromDBReturns(innerConnection, nil)

		conn = worker.NewRetryableConnection(
			lagertest.NewTestLogger("retryable-connection"),
			sleeper,