jx/internal/resource/mock_foo_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

45 lines
1.1 KiB
Go

// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
package resource
import (
"decl/internal/types"
"decl/internal/data"
"decl/internal/folio"
"net/url"
)
var (
TestConverterTypes *types.Types[data.Converter] = types.New[data.Converter]()
)
func RegisterConverterMocks() {
TestConverterTypes.Register([]string{"file"}, func(u *url.URL) data.Converter {
f := NewFileConverter()
return f
})
}
func NewFileConverter() *MockConverter {
return &MockConverter {
InjectType: func() data.TypeName { return "file" },
InjectEmit: func(document data.Document, filter data.ElementSelector) (data.Resource, error) {
return nil, nil
},
InjectExtract: func(resource data.Resource, filter data.ElementSelector) (document data.Document, err error) {
document = folio.DocumentRegistry.NewDocument("")
return
},
InjectExtractMany: func(resource data.Resource, filter data.ElementSelector) ([]data.Document, error) {
return nil, nil
},
InjectEmitMany: func(documents []data.Document, filter data.ElementSelector) (data.Resource, error) {
return nil, nil
},
InjectClose: func() error {
return nil
},
}
}