<!-- PR description--> --- #### Does this PR need a docs update or release note? - [ ] ⛔ No #### Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🧹 Tech Debt/Cleanup #### Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * #<issue> #### Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual
67 lines
1.4 KiB
Go
67 lines
1.4 KiB
Go
package mock
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"io"
|
|
|
|
"github.com/alcionai/clues"
|
|
|
|
"github.com/alcionai/corso/src/internal/streamstore"
|
|
"github.com/alcionai/corso/src/pkg/backup/details"
|
|
"github.com/alcionai/corso/src/pkg/fault"
|
|
)
|
|
|
|
var _ streamstore.Streamer = &Streamer{}
|
|
|
|
type Streamer struct {
|
|
Deets map[string]*details.Details
|
|
Errors map[string]*fault.Errors
|
|
}
|
|
|
|
func (ms Streamer) Collect(context.Context, streamstore.Collectable) error {
|
|
return clues.New("not implemented")
|
|
}
|
|
|
|
func (ms Streamer) Read(
|
|
ctx context.Context,
|
|
snapshotID string,
|
|
col streamstore.Collectable,
|
|
errs *fault.Bus,
|
|
) error {
|
|
ctx = clues.Add(
|
|
ctx,
|
|
"read_snapshot_id", snapshotID,
|
|
"collectable_type", col.Type)
|
|
|
|
var mr streamstore.Marshaller
|
|
|
|
switch col.Type {
|
|
case streamstore.DetailsType:
|
|
mr = ms.Deets[snapshotID]
|
|
case streamstore.FaultErrorsType:
|
|
mr = ms.Errors[snapshotID]
|
|
default:
|
|
return clues.New("unknown type: " + col.Type).WithClues(ctx)
|
|
}
|
|
|
|
if mr == nil {
|
|
return clues.New("collectable " + col.Type + " has no marshaller").WithClues(ctx)
|
|
}
|
|
|
|
bs, err := mr.Marshal()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return col.Unmr(io.NopCloser(bytes.NewReader(bs)))
|
|
}
|
|
|
|
func (ms Streamer) Write(context.Context, *fault.Bus) (string, error) {
|
|
return "", clues.New("not implemented")
|
|
}
|
|
|
|
func (ms Streamer) Delete(context.Context, string) error {
|
|
return clues.New("not implemented")
|
|
}
|