func testBackoffCount(maxBackoffDuration time.Duration, expectedBackoffCount int) {
	It(fmt.Sprintf("sets the MaxBackoffCount to %d based on the MaxBackoffDuration %s and the CrashBackoffMinDuration", expectedBackoffCount, maxBackoffDuration), func() {
		calc := models.NewRestartCalculator(models.DefaultImmediateRestarts, maxBackoffDuration, models.DefaultMaxRestarts)
		Expect(calc.MaxBackoffCount).To(Equal(expectedBackoffCount))
	})
}
var _ = Describe("RestartCalculator", func() {

	Describe("NewRestartCalculator", func() {
		testBackoffCount(20*time.Minute, 5)
		testBackoffCount(16*time.Minute, 5)
		testBackoffCount(8*time.Minute, 4)
		testBackoffCount(119*time.Second, 2)
		testBackoffCount(120*time.Second, 2)
		testBackoffCount(models.CrashBackoffMinDuration, 0)

		It("should work...", func() {
			nanoseconds := func(seconds int) int64 {
				return int64(seconds * 1000000000)
			}

			calc := models.NewRestartCalculator(3, 119*time.Second, 200)
			Expect(calc.ShouldRestart(0, 0, 0)).To(BeTrue())
			Expect(calc.ShouldRestart(0, 0, 1)).To(BeTrue())
			Expect(calc.ShouldRestart(0, 0, 2)).To(BeTrue())

			Expect(calc.ShouldRestart(0, 0, 3)).To(BeFalse())
			Expect(calc.ShouldRestart(nanoseconds(30), 0, 3)).To(BeTrue())

			Expect(calc.ShouldRestart(nanoseconds(30), 0, 4)).To(BeFalse())
			Expect(calc.ShouldRestart(nanoseconds(59), 0, 4)).To(BeFalse())
			Expect(calc.ShouldRestart(nanoseconds(60), 0, 4)).To(BeTrue())
			Expect(calc.ShouldRestart(nanoseconds(60), 0, 5)).To(BeFalse())
			Expect(calc.ShouldRestart(nanoseconds(118), 0, 5)).To(BeFalse())
			Expect(calc.ShouldRestart(nanoseconds(119), 0, 5)).To(BeTrue())
		})
	})