"errors"
	"io/ioutil"
	"os"
	"path/filepath"
	"time"

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

	"github.com/concourse/pool-resource/out"
	fakes "github.com/concourse/pool-resource/out/fakes"
)

var _ = Describe("Lock Pool", func() {
	var lockPool out.LockPool
	var fakeLockHandler *fakes.FakeLockHandler
	var output *gbytes.Buffer

	ValidateSharedBehaviorDuringBroadcastFailures := func(operationUnderTest func() error, additionalValidation func(int)) {

		ValidateInteractionsWithLockHandler := func(expectedNumberOfInteractions int) {
			Ω(fakeLockHandler.BroadcastLockPoolCallCount()).Should(Equal(expectedNumberOfInteractions))
			additionalValidation(expectedNumberOfInteractions)
		}

		Context("when broadcasting fails with ", func() {
			Context("for an unexpected reason", func() {
				BeforeEach(func() {
					called := false
	"errors"
	"io/ioutil"
	"os"
	"path/filepath"
	"time"

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

	"github.com/concourse/pool-resource/out"
	fakes "github.com/concourse/pool-resource/out/fakes"
)

var _ = Describe("Lock Pool", func() {
	var lockPool out.LockPool
	var fakeLockHandler *fakes.FakeLockHandler
	var output *gbytes.Buffer

	BeforeEach(func() {
		fakeLockHandler = new(fakes.FakeLockHandler)

		output = gbytes.NewBuffer()

		lockPool = out.LockPool{
			Source: out.Source{
				URI:        "some-uri",
				Pool:       "my-pool",
				Branch:     "some-branch",
				RetryDelay: 100 * time.Millisecond,
			},