Expect(err).NotTo(HaveOccurred())

				Expect(response.Error).To(Equal(models.ErrUnknownError))
			})

			It("does not try to create actual LRPs", func() {
				Expect(fakeActualLRPDB.CreateUnclaimedActualLRPCallCount()).To(Equal(0))
			})
		})
	})

	Describe("UpdateDesiredLRP", func() {
		var (
			processGuid      string
			update           *models.DesiredLRPUpdate
			beforeDesiredLRP *models.DesiredLRP
			afterDesiredLRP  *models.DesiredLRP

			requestBody interface{}
		)

		BeforeEach(func() {
			processGuid = "some-guid"
			someText := "some-text"
			beforeDesiredLRP = model_helpers.NewValidDesiredLRP(processGuid)
			beforeDesiredLRP.Instances = 4
			afterDesiredLRP = model_helpers.NewValidDesiredLRP(processGuid)
			afterDesiredLRP.Annotation = someText

			update = &models.DesiredLRPUpdate{
				Annotation: &someText,
			}
Example #2
0
package models_test

import (
	"encoding/json"

	"code.cloudfoundry.org/bbs/models"
	"github.com/gogo/protobuf/proto"

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

var _ = Describe("Routes", func() {
	var update models.DesiredLRPUpdate
	var aJson models.DesiredLRPUpdate
	var aProto models.DesiredLRPUpdate

	itSerializes := func(routes *models.Routes) {
		BeforeEach(func() {
			update = models.DesiredLRPUpdate{
				Routes: routes,
			}

			b, err := json.Marshal(update)
			Expect(err).NotTo(HaveOccurred())
			err = json.Unmarshal(b, &aJson)
			Expect(err).NotTo(HaveOccurred())

			b, err = proto.Marshal(&update)
			Expect(err).NotTo(HaveOccurred())
			err = proto.Unmarshal(b, &aProto)
Example #3
0
				Expect(schemaPath).To(Equal(etcd.DesiredLRPSchedulingInfoSchemaPath(lrp.ProcessGuid)))
			})
		})

		Context("when the desired LRP does not exist", func() {
			It("returns a resource not found error", func() {
				err := etcdDB.RemoveDesiredLRP(logger, "monkey")
				Expect(err).To(Equal(models.ErrResourceNotFound))
			})
		})
	})

	Describe("UpdateDesiredLRP", func() {
		var (
			update     *models.DesiredLRPUpdate
			desiredLRP *models.DesiredLRP
			lrp        *models.DesiredLRP
		)

		BeforeEach(func() {
			lrp = model_helpers.NewValidDesiredLRP("some-process-guid")
			lrp.Instances = 5
			err := etcdDB.DesireLRP(logger, lrp)
			Expect(err).NotTo(HaveOccurred())

			desiredLRP, err = etcdDB.DesiredLRPByProcessGuid(logger, lrp.ProcessGuid)
			Expect(err).NotTo(HaveOccurred())

			update = &models.DesiredLRPUpdate{}
		})
Example #4
0
				desiredLRP.CachedDependencies = []*models.CachedDependency{
					{
						To:                "here",
						From:              "there",
						ChecksumAlgorithm: "md5",
					},
				}
				desiredLRP.LegacyDownloadUser = "******"
				assertDesiredLRPValidationFailsWithMessage(desiredLRP, "value")
			})
		})
	})
})

var _ = Describe("DesiredLRPUpdate", func() {
	var desiredLRPUpdate models.DesiredLRPUpdate

	BeforeEach(func() {
		two := int32(2)
		someText := "some-text"
		desiredLRPUpdate.Instances = &two
		desiredLRPUpdate.Annotation = &someText
	})

	Describe("Validate", func() {
		var assertDesiredLRPValidationFailsWithMessage = func(lrp models.DesiredLRPUpdate, substring string) {
			validationErr := lrp.Validate()
			Expect(validationErr).To(HaveOccurred())
			Expect(validationErr.Error()).To(ContainSubstring(substring))
		}