Add AddItemExtensioner interface
This commit is contained in:
parent
81bee48ed7
commit
e1cf901d88
@ -22,14 +22,27 @@ type CorsoItemExtensionFactory func(
|
|||||||
*details.ExtensionInfo,
|
*details.ExtensionInfo,
|
||||||
) (CorsoItemExtension, error)
|
) (CorsoItemExtension, error)
|
||||||
|
|
||||||
|
type AddItemExtensioner interface {
|
||||||
|
AddItemExtensions(
|
||||||
|
context.Context,
|
||||||
|
io.ReadCloser,
|
||||||
|
details.ItemInfo,
|
||||||
|
[]CorsoItemExtensionFactory,
|
||||||
|
) (io.ReadCloser, *details.ExtensionInfo, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ AddItemExtensioner = &ItemExtensionHandler{}
|
||||||
|
|
||||||
|
type ItemExtensionHandler struct{}
|
||||||
|
|
||||||
// AddItemExtensions wraps provided readcloser with extensions
|
// AddItemExtensions wraps provided readcloser with extensions
|
||||||
// supplied via factory
|
// supplied via factory
|
||||||
func AddItemExtensions(
|
func (eh *ItemExtensionHandler) AddItemExtensions(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
rc io.ReadCloser,
|
rc io.ReadCloser,
|
||||||
info details.ItemInfo,
|
info details.ItemInfo,
|
||||||
factories []CorsoItemExtensionFactory,
|
factories []CorsoItemExtensionFactory,
|
||||||
) (CorsoItemExtension, *details.ExtensionInfo, error) {
|
) (io.ReadCloser, *details.ExtensionInfo, error) {
|
||||||
// TODO: move to validate
|
// TODO: move to validate
|
||||||
if rc == nil {
|
if rc == nil {
|
||||||
return nil, nil, clues.New("nil inner readcloser")
|
return nil, nil, clues.New("nil inner readcloser")
|
||||||
|
|||||||
@ -18,6 +18,8 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/logger"
|
"github.com/alcionai/corso/src/pkg/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var _ CorsoItemExtension = &MockExtension{}
|
||||||
|
|
||||||
// Temporary, testing purposes only
|
// Temporary, testing purposes only
|
||||||
type MockExtension struct {
|
type MockExtension struct {
|
||||||
// TODO: Add cumlulative crc32 checksum
|
// TODO: Add cumlulative crc32 checksum
|
||||||
@ -265,8 +267,9 @@ func (suite *ExtensionsUnitSuite) TestAddItemExtensions() {
|
|||||||
t := suite.T()
|
t := suite.T()
|
||||||
ctx, flush := tester.NewContext(t)
|
ctx, flush := tester.NewContext(t)
|
||||||
defer flush()
|
defer flush()
|
||||||
|
ith := &ItemExtensionHandler{}
|
||||||
|
|
||||||
extRc, extInfo, err := AddItemExtensions(
|
extRc, extInfo, err := ith.AddItemExtensions(
|
||||||
ctx,
|
ctx,
|
||||||
test.rc,
|
test.rc,
|
||||||
testItemInfo,
|
testItemInfo,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user