github.com/leowmjw/otto@v0.2.1-0.20160126165905-6400716cf085/app/mock.go (about) 1 package app 2 3 import ( 4 "github.com/hashicorp/otto/appfile" 5 ) 6 7 // Mock is a mock implementation of the App interface. 8 type Mock struct { 9 CloseCalled bool 10 11 MetaCalled bool 12 MetaResult *Meta 13 MetaErr error 14 15 ImplicitCalled bool 16 ImplicitContext *Context 17 ImplicitResult *appfile.File 18 ImplicitErr error 19 20 CompileCalled bool 21 CompileContext *Context 22 CompileResult *CompileResult 23 CompileErr error 24 CompileFunc func(ctx *Context) (*CompileResult, error) 25 26 BuildCalled bool 27 BuildContext *Context 28 BuildErr error 29 30 DeployCalled bool 31 DeployContext *Context 32 DeployErr error 33 34 DevCalled bool 35 DevContext *Context 36 DevErr error 37 38 DevDepCalled bool 39 DevDepContextDst *Context 40 DevDepContextSrc *Context 41 DevDepResult *DevDep 42 DevDepErr error 43 } 44 45 func (m *Mock) Meta() (*Meta, error) { 46 m.MetaCalled = true 47 return m.MetaResult, m.MetaErr 48 } 49 50 func (m *Mock) Close() error { 51 m.CloseCalled = true 52 return nil 53 } 54 55 func (m *Mock) Implicit(ctx *Context) (*appfile.File, error) { 56 m.ImplicitCalled = true 57 m.ImplicitContext = ctx 58 return m.ImplicitResult, m.ImplicitErr 59 } 60 61 func (m *Mock) Compile(ctx *Context) (*CompileResult, error) { 62 m.CompileCalled = true 63 m.CompileContext = ctx 64 if m.CompileFunc != nil { 65 return m.CompileFunc(ctx) 66 } 67 return m.CompileResult, m.CompileErr 68 } 69 70 func (m *Mock) Build(ctx *Context) error { 71 m.BuildCalled = true 72 m.BuildContext = ctx 73 return m.BuildErr 74 } 75 76 func (m *Mock) Deploy(ctx *Context) error { 77 m.DeployCalled = true 78 m.DeployContext = ctx 79 return m.DeployErr 80 } 81 82 func (m *Mock) Dev(ctx *Context) error { 83 m.DevCalled = true 84 m.DevContext = ctx 85 return m.DevErr 86 } 87 88 func (m *Mock) DevDep(dst, src *Context) (*DevDep, error) { 89 m.DevDepCalled = true 90 m.DevDepContextDst = dst 91 m.DevDepContextSrc = src 92 return m.DevDepResult, m.DevDepErr 93 }