本文整理汇总了Golang中github.com/concourse/atc/exec/fakes.FakeStep.ResultStub方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeStep.ResultStub方法的具体用法?Golang FakeStep.ResultStub怎么用?Golang FakeStep.ResultStub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/concourse/atc/exec/fakes.FakeStep
的用法示例。
在下文中一共展示了FakeStep.ResultStub方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
Source: atc.Source{"some": "source"},
}
params = atc.Params{"some-param": "some-value"}
version = atc.Version{"some-version": "some-value"}
tags = []string{"some", "tags"}
inStep = new(fakes.FakeStep)
inStep.ResultStub = func(x interface{}) bool {
switch v := x.(type) {
case *VersionInfo:
*v = VersionInfo{
Version: version,
}
return true
default:
return false
}
}
repo = NewSourceRepository()
})
JustBeforeEach(func() {
step = factory.DependentGet(sourceName, identifier, getDelegate, resourceConfig, tags, params).Using(inStep, repo)
process = ifrit.Invoke(step)
})
Context("when the tracker can initialize the resource", func() {
示例2:
attempt2Factory = new(fakes.FakeStepFactory)
attempt2Step = new(fakes.FakeStep)
attempt2Factory.UsingReturns(attempt2Step)
attempt3Factory = new(fakes.FakeStepFactory)
attempt3Step = new(fakes.FakeStep)
attempt3Factory.UsingReturns(attempt3Step)
stepFactory = Retry{attempt1Factory, attempt2Factory, attempt3Factory}
step = stepFactory.Using(nil, nil)
})
Context("when attempt 1 succeeds", func() {
BeforeEach(func() {
attempt1Step.ResultStub = successResult(true)
})
Describe("Run", func() {
var process ifrit.Process
JustBeforeEach(func() {
process = ifrit.Invoke(step)
})
It("returns nil having only run the first attempt", func() {
Expect(<-process.Wait()).ToNot(HaveOccurred())
Expect(attempt1Step.RunCallCount()).To(Equal(1))
Expect(attempt2Step.RunCallCount()).To(Equal(0))
Expect(attempt3Step.RunCallCount()).To(Equal(0))
示例3:
taskStep *execfakes.FakeStep
inputStepFactory *execfakes.FakeStepFactory
inputStep *execfakes.FakeStep
outputStepFactory *execfakes.FakeStepFactory
outputStep *execfakes.FakeStep
dependentStepFactory *execfakes.FakeStepFactory
dependentStep *execfakes.FakeStep
)
BeforeEach(func() {
taskStepFactory = new(execfakes.FakeStepFactory)
taskStep = new(execfakes.FakeStep)
taskStep.ResultStub = successResult(true)
taskStepFactory.UsingReturns(taskStep)
fakeFactory.TaskReturns(taskStepFactory)
inputStepFactory = new(execfakes.FakeStepFactory)
inputStep = new(execfakes.FakeStep)
inputStep.ResultStub = successResult(true)
inputStepFactory.UsingReturns(inputStep)
fakeFactory.GetReturns(inputStepFactory)
outputStepFactory = new(execfakes.FakeStepFactory)
outputStep = new(execfakes.FakeStep)
outputStep.ResultStub = successResult(true)
outputStepFactory.UsingReturns(outputStep)
fakeFactory.PutReturns(outputStepFactory)
示例4:
step = &fakes.FakeStep{}
hook = &fakes.FakeStep{}
previousStep = &fakes.FakeStep{}
stepFactory.UsingReturns(step)
hookFactory.UsingReturns(hook)
repo = exec.NewSourceRepository()
ensureFactory = exec.Ensure(stepFactory, hookFactory)
ensureStep = ensureFactory.Using(previousStep, repo)
})
It("runs the ensure hook if the step succeeds", func() {
step.ResultStub = successResult(true)
process := ifrit.Background(ensureStep)
Eventually(step.RunCallCount).Should(Equal(1))
Eventually(hook.RunCallCount).Should(Equal(1))
Eventually(process.Wait()).Should(Receive(noError()))
})
It("runs the ensure hook if the step fails", func() {
step.ResultStub = successResult(false)
process := ifrit.Background(ensureStep)
Eventually(step.RunCallCount).Should(Equal(1))
示例5:
conditional Conditional
outStep *fakes.FakeStep
step Step
process ifrit.Process
)
BeforeEach(func() {
inStep = new(fakes.FakeStep)
repo = NewSourceRepository()
fakeStepFactory = new(fakes.FakeStepFactory)
outStep = new(fakes.FakeStep)
outStep.ResultStub = successResult(true)
fakeStepFactory.UsingReturns(outStep)
conditional = Conditional{
StepFactory: fakeStepFactory,
}
})
JustBeforeEach(func() {
step = conditional.Using(inStep, repo)
process = ifrit.Invoke(step)
})
itDoesNothing := func() {
It("succeeds", func() {
示例6:
Describe("Resume", func() {
Context("get with nil location", func() {
var (
getStepFactory *execfakes.FakeStepFactory
getStep *execfakes.FakeStep
fakeDelegate *fakes.FakeBuildDelegate
fakeGetDelegate *execfakes.FakeGetDelegate
plan atc.Plan
)
BeforeEach(func() {
getStepFactory = new(execfakes.FakeStepFactory)
getStep = new(execfakes.FakeStep)
getStep.ResultStub = successResult(true)
getStepFactory.UsingReturns(getStep)
fakeFactory.GetReturns(getStepFactory)
fakeDelegate = new(fakes.FakeBuildDelegate)
fakeDelegateFactory.DelegateReturns(fakeDelegate)
fakeGetDelegate = new(execfakes.FakeGetDelegate)
fakeDelegate.InputDelegateReturns(fakeGetDelegate)
plan = atc.Plan{
Location: nil,
Get: &atc.GetPlan{
Name: "some input",
},
}
示例7:
It("returns false", func() {
result := "this-is-bad"
Ω(step.Result(&result)).Should(BeFalse())
})
})
Context("when getting a Success result", func() {
var result Success
BeforeEach(func() {
result = false
})
Context("and all branches are successful", func() {
BeforeEach(func() {
outStepA.ResultStub = successResult(true)
outStepB.ResultStub = successResult(true)
})
It("yields true", func() {
Ω(step.Result(&result)).Should(BeTrue())
Ω(result).Should(Equal(Success(true)))
})
})
Context("and some branches are not successful", func() {
BeforeEach(func() {
outStepA.ResultStub = successResult(true)
outStepB.ResultStub = successResult(false)
})
示例8:
buildModel = db.Build{ID: 84}
})
Context("running timeout steps", func() {
var (
taskStepFactory *execfakes.FakeStepFactory
taskStep *execfakes.FakeStep
inputStepFactory *execfakes.FakeStepFactory
inputStep *execfakes.FakeStep
)
BeforeEach(func() {
taskStepFactory = new(execfakes.FakeStepFactory)
taskStep = new(execfakes.FakeStep)
taskStep.ResultStub = successResult(true)
taskStepFactory.UsingReturns(taskStep)
fakeFactory.TaskReturns(taskStepFactory)
inputStepFactory = new(execfakes.FakeStepFactory)
inputStep = new(execfakes.FakeStep)
inputStep.ResultStub = successResult(true)
inputStepFactory.UsingReturns(inputStep)
fakeFactory.GetReturns(inputStepFactory)
})
Context("constructing steps", func() {
var (
fakeDelegate *fakes.FakeBuildDelegate
fakeInputDelegate *execfakes.FakeGetDelegate
timeout string
示例9:
inStep = new(fakes.FakeStep)
repo = NewSourceRepository()
outStep = new(fakes.FakeStep)
fakeStepFactoryStep.UsingReturns(outStep)
nextStep = new(fakes.FakeStep)
fakeStepFactoryNextStep.UsingReturns(nextStep)
startStep = make(chan error, 1)
finishStep = make(chan error, 1)
startNextStep = make(chan error, 1)
finishNextStep = make(chan error, 1)
outStep.ResultStub = successResult(true)
outStep.RunStub = func(signals <-chan os.Signal, ready chan<- struct{}) error {
select {
case err := <-startStep:
if err != nil {
return err
}
case <-signals:
return ErrInterrupted
}
close(ready)
select {
case <-signals:
return ErrInterrupted
示例10:
It("assigns the provided interface to Success(true)", func() {
step.Result(x)
Expect(*x).Should(Equal(Success(true)))
})
})
Context("when compared against something other than Success", func() {
const exitCode = 1234
BeforeEach(func() {
runStep.ResultStub = func(x interface{}) bool {
switch v := x.(type) {
case *ExitStatus:
*v = ExitStatus(exitCode)
return true
default:
panic("unexpected Result comparison")
}
}
})
It("deletegates to the inner step", func() {
x := new(ExitStatus)
result := step.Result(x)
Expect(result).Should(Equal(true))
Expect(*x).Should(Equal(ExitStatus(exitCode)))
})
})
})
示例11:
It("exits successfully", func() {
Eventually(process.Wait()).Should(Receive(BeNil()))
})
Describe("releasing", func() {
It("releases both sources", func() {
Eventually(process.Wait()).Should(Receive(BeNil()))
step.Release()
Ω(outStepA.ReleaseCallCount()).Should(Equal(1))
Ω(outStepB.ReleaseCallCount()).Should(Equal(1))
})
})
Describe("getting the result", func() {
BeforeEach(func() {
outStepB.ResultStub = successResult(true)
})
It("delegates to the second source", func() {
Eventually(process.Wait()).Should(Receive(BeNil()))
var success Success
Ω(step.Result(&success)).Should(BeTrue())
Ω(bool(success)).Should(BeTrue())
})
})
})
Context("and the second source exits with an error", func() {
disaster := errors.New("nope")