github.com/buildpacks/pack@v0.33.3-0.20240516162812-884dd1837311/pkg/testmocks/mock_image.go (about) 1 package testmocks 2 3 import ( 4 "github.com/buildpacks/imgutil" 5 "github.com/buildpacks/imgutil/fakes" 6 ) 7 8 type MockImage struct { 9 *fakes.Image 10 EntrypointCall struct { 11 callCount int 12 Received struct{} 13 Returns struct { 14 StringArr []string 15 Error error 16 } 17 Stub func() ([]string, error) 18 } 19 } 20 21 func NewImage(name, topLayerSha string, identifier imgutil.Identifier) *MockImage { 22 return &MockImage{ 23 Image: fakes.NewImage(name, topLayerSha, identifier), 24 } 25 } 26 27 func (m *MockImage) Entrypoint() ([]string, error) { 28 if m.EntrypointCall.Stub != nil { 29 return m.EntrypointCall.Stub() 30 } 31 return m.EntrypointCall.Returns.StringArr, m.EntrypointCall.Returns.Error 32 }