jx/internal/resource/mock_converter_test.go
Matthew Rich 8094d1c063
Some checks are pending
Lint / golangci-lint (push) Waiting to run
Declarative Tests / test (push) Waiting to run
Declarative Tests / build-fedora (push) Waiting to run
Declarative Tests / build-ubuntu-focal (push) Waiting to run
add build support to container_image resource; add more testing
2024-09-19 08:11:57 +00:00

41 lines
1.4 KiB
Go

// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
package resource
import (
"decl/internal/data"
)
type MockConverter struct {
InjectType func() data.TypeName
InjectEmit func(document data.Document, filter data.ElementSelector) (data.Resource, error)
InjectExtract func(resource data.Resource, filter data.ElementSelector) (data.Document, error)
InjectExtractMany func(resource data.Resource, filter data.ElementSelector) ([]data.Document, error)
InjectEmitMany func(documents []data.Document, filter data.ElementSelector) (data.Resource, error)
InjectClose func() error
}
func (m *MockConverter) Emit(document data.Document, filter data.ElementSelector) (data.Resource, error) {
return m.InjectEmit(document, filter)
}
func (m *MockConverter) EmitMany(documents []data.Document, filter data.ElementSelector) (data.Resource, error) {
return m.InjectEmitMany(documents, filter)
}
func (m *MockConverter) Extract(resource data.Resource, filter data.ElementSelector) (data.Document, error) {
return m.InjectExtract(resource, filter)
}
func (m *MockConverter) ExtractMany(resource data.Resource, filter data.ElementSelector) ([]data.Document, error) {
return m.InjectExtractMany(resource, filter)
}
func (m *MockConverter) Type() data.TypeName {
return m.InjectType()
}
func (m *MockConverter) Close() error {
return m.InjectClose()
}