func (f *FakeManagerFactory) SetNewManagerBehavior(cloud bicloud.Cloud, manager bistemcell.Manager) { input := NewManagerInput{ Cloud: cloud, } inputString, marshalErr := bitestutils.MarshalToString(input) if marshalErr != nil { panic(bosherr.WrapError(marshalErr, "Marshaling NewManager input")) } f.newManagerBehavior[inputString] = newManagerOutput{manager: manager} }
func (f *FakeERBRenderer) SetRenderBehavior(srcPath, dstPath string, context bierbrenderer.TemplateEvaluationContext, err error) error { input := RenderInput{ SrcPath: srcPath, DstPath: dstPath, Context: context, } inputString, marshalErr := bitestutils.MarshalToString(input) if marshalErr != nil { return bosherr.WrapError(marshalErr, "Marshaling Find input") } f.renderBehavior[inputString] = renderOutput{err: err} return nil }
func (f *FakeManagerFactory) NewManager(cloud bicloud.Cloud) bistemcell.Manager { input := NewManagerInput{ Cloud: cloud, } f.NewManagerInputs = append(f.NewManagerInputs, input) inputString, marshalErr := bitestutils.MarshalToString(input) if marshalErr != nil { panic(bosherr.WrapError(marshalErr, "Marshaling NewManager input")) } output, found := f.newManagerBehavior[inputString] if !found { panic(fmt.Errorf("Unsupported NewManager Input: %#v\nExpected Behavior: %#v", input, f.newManagerBehavior)) } return output.manager }
func (fr *FakeStemcellRepo) SetFindBehavior(name, version string, foundRecord biconfig.StemcellRecord, found bool, err error) error { input := StemcellRepoFindInput{ Name: name, Version: version, } inputString, marshalErr := bitestutils.MarshalToString(input) if marshalErr != nil { return bosherr.WrapError(marshalErr, "Marshaling Find input") } fr.FindBehavior[inputString] = StemcellRepoFindOutput{ stemcellRecord: foundRecord, found: found, err: err, } return nil }
func (fr *FakeStemcellRepo) Find(name, version string) (biconfig.StemcellRecord, bool, error) { input := StemcellRepoFindInput{ Name: name, Version: version, } fr.FindInputs = append(fr.FindInputs, input) inputString, marshalErr := bitestutils.MarshalToString(input) if marshalErr != nil { return biconfig.StemcellRecord{}, false, bosherr.WrapError(marshalErr, "Marshaling Find input") } output, found := fr.FindBehavior[inputString] if !found { return biconfig.StemcellRecord{}, false, fmt.Errorf("Unsupported Find Input: %s", inputString) } return output.stemcellRecord, output.found, output.err }
func (fr *FakeStemcellRepo) SetSaveBehavior(name, version, cid string, stemcellRecord biconfig.StemcellRecord, err error) error { input := StemcellRepoSaveInput{ Name: name, Version: version, CID: cid, } inputString, marshalErr := bitestutils.MarshalToString(input) if marshalErr != nil { return bosherr.WrapError(marshalErr, "Marshaling Save input") } fr.SaveBehavior[inputString] = StemcellRepoSaveOutput{ stemcellRecord: stemcellRecord, err: err, } return nil }
func (fr *FakeStemcellRepo) Save(name, version, cid string) (biconfig.StemcellRecord, error) { input := StemcellRepoSaveInput{ Name: name, Version: version, CID: cid, } fr.SaveInputs = append(fr.SaveInputs, input) inputString, marshalErr := bitestutils.MarshalToString(input) if marshalErr != nil { return biconfig.StemcellRecord{}, bosherr.WrapError(marshalErr, "Marshaling Save input") } output, found := fr.SaveBehavior[inputString] if !found { return biconfig.StemcellRecord{}, fmt.Errorf("Unsupported Save Input: %s", inputString) } return output.stemcellRecord, output.err }
func (f *FakeERBRenderer) Render(srcPath, dstPath string, context bierbrenderer.TemplateEvaluationContext) error { input := RenderInput{ SrcPath: srcPath, DstPath: dstPath, Context: context, } f.RenderInputs = append(f.RenderInputs, input) inputString, marshalErr := bitestutils.MarshalToString(input) if marshalErr != nil { return bosherr.WrapError(marshalErr, "Marshaling Find input") } output, found := f.renderBehavior[inputString] if found { return output.err } return fmt.Errorf("Unsupported Input: Render('%s', '%s', '%s')", srcPath, dstPath, context) }