-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better structure the code for testability.
- Loading branch information
Mathieu Leduc-Hamel
committed
Apr 6, 2021
1 parent
5bfd4cf
commit b0db95b
Showing
9 changed files
with
117 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package jobs | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/mlhamel/trieugene/pkg/config" | ||
) | ||
|
||
type DummyManager struct { | ||
cfg *config.Config | ||
} | ||
|
||
func NewDummyManager(cfg *config.Config) Manager { | ||
return &DummyManager{} | ||
} | ||
|
||
func (f *DummyManager) Register(job Job) error { | ||
return nil | ||
} | ||
|
||
func (d *DummyManager) Perform(job Job, msgs ...*Message) error { | ||
return nil | ||
} | ||
|
||
func (f *DummyManager) Run(ctx context.Context) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package jobs | ||
|
||
import "context" | ||
|
||
type ExpectsJob struct { | ||
Called bool | ||
} | ||
|
||
func (e *ExpectsJob) Kind() string { | ||
return "expected-job" | ||
} | ||
|
||
func (e *ExpectsJob) Perform(ctx context.Context, args ...interface{}) error { | ||
e.Called = true | ||
return nil | ||
} | ||
|
||
func (e *ExpectsJob) Run(ctx context.Context, args ...interface{}) error { | ||
return e.Perform(ctx, args) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package scraper | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/mlhamel/trieugene/pkg/config" | ||
) | ||
|
||
type DummyScraper struct { | ||
cfg *config.Config | ||
} | ||
|
||
func NewDummyScraper(cfg *config.Config) Scraper { | ||
return &HttpScraper{ | ||
cfg: cfg, | ||
} | ||
} | ||
|
||
func (d *DummyScraper) Run(ctx context.Context) ([][]string, error) { | ||
return [][]string{}, nil | ||
} |
File renamed without changes.