jx/tests/mocks/resource.go

36 lines
758 B
Go
Raw Normal View History

2024-03-20 19:23:31 +00:00
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
2024-03-20 16:15:27 +00:00
package mocks
2024-03-20 19:23:31 +00:00
import (
"context"
_ "gopkg.in/yaml.v3"
)
2024-03-20 16:15:27 +00:00
type MockResource struct {
2024-03-20 19:23:31 +00:00
InjectURI func() string
InjectType func() string
2024-03-20 16:15:27 +00:00
InjectLoadDecl func(string) error
InjectApply func() error
2024-03-20 19:23:31 +00:00
InjectRead func(context.Context) ([]byte, error)
}
func (m *MockResource) URI() string {
return m.InjectURI()
2024-03-20 16:15:27 +00:00
}
func (m *MockResource) LoadDecl(yamlResourceDeclaration string) error {
return m.InjectLoadDecl(yamlResourceDeclaration)
}
func (m *MockResource) Apply() error {
return m.InjectApply()
}
2024-03-20 19:23:31 +00:00
func (m *MockResource) Read(ctx context.Context) ([]byte, error) {
return m.InjectRead(ctx)
}
func (m *MockResource) Type() string {
return m.InjectType()
}