Skip to content
Snippets Groups Projects
Commit 1791c2bc authored by Danis Kirasirov's avatar Danis Kirasirov
Browse files

Использование Stub вместо Dummy

parent 7b630eb7
No related branches found
No related tags found
No related merge requests found
...@@ -18,17 +18,21 @@ func (d *Dummy) Find(_ context.Context, _, _, _ string, _ *Filter, _ ...*FindOpt ...@@ -18,17 +18,21 @@ func (d *Dummy) Find(_ context.Context, _, _, _ string, _ *Filter, _ ...*FindOpt
return d.FindResult.Items, d.FindResult.Total, d.FindResult.Error return d.FindResult.Items, d.FindResult.Total, d.FindResult.Error
} }
type DummyWithOptions struct { type StubFindResult struct {
Items
Total int Total int
} }
func (d *DummyWithOptions) Find(_ context.Context, _, _, _ string, _ *Filter, opts ...*FindOptions) ([]*Item, int, error) { type Stub struct {
Items
FindResult *StubFindResult
}
func (d *Stub) Find(_ context.Context, _, _, _ string, _ *Filter, opts ...*FindOptions) ([]*Item, int, error) {
fo := MergeFindOptions(opts...) fo := MergeFindOptions(opts...)
return make([]*Item, fo.Limit), d.Total, nil return make([]*Item, fo.Limit), d.FindResult.Total, nil
} }
func (d *DummyWithOptions) FindPublished(_ context.Context, _, _, _ string, _ *Filter, opts ...*FindPublishedOptions) ([]*Item, int, error) { func (d *Stub) FindPublished(_ context.Context, _, _, _ string, _ *Filter, opts ...*FindPublishedOptions) ([]*Item, int, error) {
fo := MergeFindPublishedOptions(opts...) fo := MergeFindPublishedOptions(opts...)
return make([]*Item, fo.Limit), d.Total, nil return make([]*Item, fo.Limit), d.FindResult.Total, nil
} }
...@@ -35,7 +35,7 @@ func TestBatchProcessor(t *testing.T) { ...@@ -35,7 +35,7 @@ func TestBatchProcessor(t *testing.T) {
}) })
t.Run("With FindOptions", func(t *testing.T) { t.Run("With FindOptions", func(t *testing.T) {
itemssvc := &DummyWithOptions{Items: nil, Total: 1000} itemssvc := &Stub{FindResult: &StubFindResult{Total: 1000}}
b := &BatchProcessor{ b := &BatchProcessor{
Items: itemssvc, Items: itemssvc,
SpaceID: "sp", SpaceID: "sp",
...@@ -51,7 +51,7 @@ func TestBatchProcessor(t *testing.T) { ...@@ -51,7 +51,7 @@ func TestBatchProcessor(t *testing.T) {
}) })
t.Run("With FindPublishedOptions", func(t *testing.T) { t.Run("With FindPublishedOptions", func(t *testing.T) {
itemssvc := &DummyWithOptions{Items: nil, Total: 60} itemssvc := &Stub{FindResult: &StubFindResult{Total: 60}}
b := &BatchProcessor{ b := &BatchProcessor{
Items: itemssvc, Items: itemssvc,
SpaceID: "sp", SpaceID: "sp",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment