Ejemplo n.º 1
0
				Name: "some-resource",
				Type: "some-type",
				Source: atc.Source{
					"source-config": "some-value",
				},
			},
		},
	}

	BeforeEach(func() {
		team, err := sqlDB.SaveTeam(db.Team{Name: "some-team"})
		Expect(err).NotTo(HaveOccurred())
		_, _, err = sqlDB.SaveConfig(team.Name, "pipeline-name", pipelineConfig, 0, db.PipelineUnpaused)
		Expect(err).NotTo(HaveOccurred())

		savedPipeline, err := sqlDB.GetPipelineByTeamNameAndName(team.Name, "pipeline-name")
		Expect(err).NotTo(HaveOccurred())

		pipelineDB = pipelineDBFactory.Build(savedPipeline)
	})

	Describe("taking out a lease on pipeline scheduling", func() {
		Context("when it has been scheduled recently", func() {
			It("does not get the lease", func() {
				lease, leased, err := pipelineDB.LeaseScheduling(1 * time.Second)
				Expect(err).NotTo(HaveOccurred())
				Expect(leased).To(BeTrue())

				lease.Break()

				_, leased, err = pipelineDB.LeaseScheduling(1 * time.Second)
Ejemplo n.º 2
0
		var pipelineName string
		BeforeEach(func() {
			pipelineName = "a-pipeline-name"
		})

		It("returns true for created", func() {
			_, created, err := database.SaveConfig(team.Name, pipelineName, config, 0, db.PipelineNoChange)
			Expect(err).NotTo(HaveOccurred())
			Expect(created).To(BeTrue())
		})

		It("caches the team id", func() {
			_, _, err := database.SaveConfig(team.Name, pipelineName, config, 0, db.PipelineNoChange)
			Expect(err).NotTo(HaveOccurred())

			pipeline, err := database.GetPipelineByTeamNameAndName(team.Name, pipelineName)
			Expect(err).NotTo(HaveOccurred())
			Expect(pipeline.TeamID).To(Equal(team.ID))
		})

		It("can be saved as paused", func() {
			_, _, err := database.SaveConfig(team.Name, pipelineName, config, 0, db.PipelinePaused)
			Expect(err).NotTo(HaveOccurred())

			pipeline, err := database.GetPipelineByTeamNameAndName(team.Name, pipelineName)
			Expect(err).NotTo(HaveOccurred())

			Expect(pipeline.Paused).To(BeTrue())
		})

		It("can be saved as unpaused", func() {