コード例 #1
0
ファイル: queue_test.go プロジェクト: FireEater64/gamq
func TestQueue_CloseQueueImmediately_ThrowsNoErrors(t *testing.T) {
	gomega.RegisterTestingT(t)
	underTest := NewQueue("Test")

	close(underTest.InputChannel)

	gomega.Eventually(func() bool {
		_, open := <-underTest.OutputChannel
		return open
	}).Should(gomega.BeFalse())
}
コード例 #2
0
ファイル: run_policy.go プロジェクト: LalatenduMohanty/origin
				LabelSelector: buildutil.BuildConfigSelector(bcName),
			})
			defer buildWatch.Stop()

			// Start first build
			stdout, _, err := exutil.StartBuild(oc, bcName, "-o=name")
			o.Expect(err).NotTo(o.HaveOccurred())
			o.Expect(strings.TrimSpace(stdout)).ShouldNot(o.HaveLen(0))
			// extract build name from "build/buildName" resource id
			startedBuilds = append(startedBuilds, strings.TrimSpace(strings.Split(stdout, "/")[1]))

			// Wait for it to become running
			for {
				event := <-buildWatch.ResultChan()
				build := event.Object.(*buildapi.Build)
				o.Expect(buildutil.IsBuildComplete(build)).Should(o.BeFalse())
				if build.Name == startedBuilds[0] && build.Status.Phase == buildapi.BuildPhaseRunning {
					break
				}
			}

			for i := 0; i < 2; i++ {
				stdout, _, err = exutil.StartBuild(oc, bcName, "-o=name")
				o.Expect(err).NotTo(o.HaveOccurred())
				o.Expect(strings.TrimSpace(stdout)).ShouldNot(o.HaveLen(0))
				startedBuilds = append(startedBuilds, strings.TrimSpace(strings.Split(stdout, "/")[1]))
			}

			o.Expect(err).NotTo(o.HaveOccurred())

			for {
コード例 #3
0
ファイル: rsync.go プロジェクト: claytonspinner/origin
				foundOriginal := false
				foundModified := false
				files, err = ioutil.ReadDir(tempDir)
				for _, f := range files {
					if strings.Contains(f.Name(), originalName) {
						foundOriginal = true
					}
					if strings.Contains(f.Name(), modifiedName) {
						foundModified = true
					}
				}
				g.By("Verifying original file is in the local directory")
				o.Expect(foundOriginal).To(o.BeTrue())

				g.By("Verifying renamed file is not in the local directory")
				o.Expect(foundModified).To(o.BeFalse())

				g.By("Getting an error if copying to a destination directory where there is no write permission")
				result, err = oc.Run("rsync").Args(
					sourcePath1,
					fmt.Sprintf("%s:/", podName),
					fmt.Sprintf("--strategy=%s", strategy)).Output()
				o.Expect(err).To(o.HaveOccurred())
			}
		}

		for _, strategy := range strategies {
			g.It(fmt.Sprintf("should copy files with the %s strategy", strategy), testRsyncFn(strategy))
		}
	})
コード例 #4
0
ファイル: slices_test.go プロジェクト: leverly/flood
	. "github.com/onsi/ginkgo"
	g "github.com/onsi/gomega"
)

var _ = Describe("Ints64", func() {
	var subject Ints64

	BeforeEach(func() {
		subject = SortInts64(4, 6, 2)
	})

	It("should normalize", func() {
		g.Expect(subject).To(g.Equal(Ints64{2, 4, 6}))
		g.Expect(subject.crc64('x')).To(g.Equal(uint64(6934466117131854228)))
	})

	It("should check if exists", func() {
		g.Expect(subject.Exists(1)).To(g.BeFalse())
		g.Expect(subject.Exists(2)).To(g.BeTrue())
		g.Expect(subject.Exists(3)).To(g.BeFalse())
		g.Expect(subject.Exists(4)).To(g.BeTrue())
	})

	It("should check for intersections", func() {
		g.Expect(subject.Inter(SortInts64(3))).To(g.BeFalse())
		g.Expect(subject.Inter(SortInts64(3, 5))).To(g.BeFalse())
		g.Expect(subject.Inter(SortInts64(3, 4, 5, 7))).To(g.BeTrue())
	})

})
コード例 #5
0
ファイル: rules_test.go プロジェクト: leverly/flood
	BeforeEach(func() {
		subject = CheckFact(FactKey(33), OneOf([]int64{3, 2, 1}))
	})

	It("should return a string", func() {
		g.Expect(subject.String()).To(g.Equal(`[33]+[1 2 3]`))
	})

	It("should have an ID", func() {
		g.Expect(subject.crc64()).To(g.Equal(uint64(3048486384098978521)))
	})

	It("should perform", func() {
		g.Expect(subject.perform(mockFact{FactKey(33): []int64{1}}, NewState())).To(g.BeTrue())
		g.Expect(subject.perform(mockFact{FactKey(33): []int64{4}}, NewState())).To(g.BeFalse())
		g.Expect(subject.perform(mockFact{FactKey(34): []int64{1}}, NewState())).To(g.BeFalse())
	})

	It("should capture state", func() {
		state := NewState()
		g.Expect(subject.perform(mockFact{FactKey(33): []int64{1}}, state)).To(g.BeTrue())
		g.Expect(state.rules).To(g.Equal(map[uint64]bool{
			3048486384098978521: true,
		}))
		g.Expect(state.facts).To(g.HaveLen(1))
		g.Expect(state.facts).To(g.HaveKey(FactKey(33)))
	})
})

var _ = Describe("conjunction", func() {
コード例 #6
0
ファイル: conditions_test.go プロジェクト: leverly/flood
	BeforeEach(func() {
		subject = EqualTo(true)
	})

	It("should return a string", func() {
		g.Expect(subject.String()).To(g.Equal(`=true`))
	})

	It("should have an ID", func() {
		g.Expect(subject.CRC64()).To(g.Equal(uint64(971422227693832935)))
		g.Expect(EqualTo(27).CRC64()).To(g.Equal(uint64(9340596851114011254)))
	})

	It("should check equality", func() {
		g.Expect(subject.Match(nil)).To(g.BeFalse())
		g.Expect(subject.Match(1)).To(g.BeFalse())
		g.Expect(subject.Match(true)).To(g.BeTrue())
		g.Expect(subject.Match(false)).To(g.BeFalse())
	})
})

var _ = Describe("NumericGreater", func() {
	var subject *NumericGreater
	var _ Condition = subject

	BeforeEach(func() {
		subject = GreaterThan(5.1)
	})

	It("should return a string", func() {