jx/internal/resource/mock_foo_converter_test.go

45 lines
1.1 KiB
Go
Raw Permalink Normal View History

// 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
},
}
}