Esempio n. 1
0
	fakeconfig "github.com/cloudfoundry/cli/cf/configuration/fakes"

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

var _ = Describe("Configuration Repository", func() {
	var (
		config    core_config.Repository
		persistor *fakeconfig.FakePersistor
	)

	BeforeEach(func() {
		persistor = &fakeconfig.FakePersistor{}
		persistor.ExistsReturns(true)
		config = core_config.NewRepositoryFromPersistor(persistor, func(err error) { panic(err) })
	})

	It("is threadsafe", func() {
		performSaveCh := make(chan struct{})
		beginSaveCh := make(chan struct{})
		finishSaveCh := make(chan struct{})
		finishReadCh := make(chan struct{})

		persistor.SaveStub = func(configuration.DataInterface) error {
			close(beginSaveCh)
			<-performSaveCh
			close(finishSaveCh)

			return nil
		}
Esempio n. 2
0
func NewRepository() core_config.Repository {
	return core_config.NewRepositoryFromPersistor(NewFakePersistor(), func(err error) {
		panic(err)
	})
}