Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added enhancement for #57 and UT coverage for #13 #58

Merged
merged 1 commit into from
Mar 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/dispatcher/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type IDispatcher interface {
// Get the attack status, params and ID for a single attack
Get(string) (*models.AttackResponse, error)
// List the attack status, params and ID for all submitted attacks.
List() []*models.AttackResponse
List(models.FilterParams) []*models.AttackResponse
}

type dispatcher struct {
Expand Down Expand Up @@ -181,12 +181,12 @@ func (d *dispatcher) Get(id string) (*models.AttackResponse, error) {
}

// List all submitted attacks
func (d *dispatcher) List() []*models.AttackResponse {
func (d *dispatcher) List(filters models.FilterParams) []*models.AttackResponse {
d.log(nil).Debug("getting attack list")

responses := make([]*models.AttackResponse, 0)

for _, attackDetails := range d.db.GetAll() {
for _, attackDetails := range d.db.GetAll(filters) {
resp := models.AttackResponse(attackDetails.AttackInfo)
responses = append(responses, &resp)
}
Expand Down
8 changes: 4 additions & 4 deletions internal/dispatcher/dispatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,11 @@ func Test_dispatcher_Get_Error_GetByID(t *testing.T) {
func Test_dispatcher_List(t *testing.T) {
mockStore := &smocks.IAttackStore{}

mockStore.On("GetAll").Return([]models.AttackDetails{{}})
mockStore.On("GetAll", make(models.FilterParams)).Return([]models.AttackDetails{{}})

d := setupDispatcher(mockStore)

got := d.List()
got := d.List(make(models.FilterParams))
if len(got) == 0 {
t.Fail()
}
Expand All @@ -327,11 +327,11 @@ func Test_dispatcher_List(t *testing.T) {
func Test_dispatcher_List_Empty(t *testing.T) {
mockStore := &smocks.IAttackStore{}

mockStore.On("GetAll").Return([]models.AttackDetails{})
mockStore.On("GetAll", make(models.FilterParams)).Return([]models.AttackDetails{})

d := setupDispatcher(mockStore)

got := d.List()
got := d.List(make(models.FilterParams))
if len(got) != 0 {
t.Fail()
}
Expand Down
10 changes: 5 additions & 5 deletions internal/dispatcher/mocks/IDispatcher.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

161 changes: 161 additions & 0 deletions internal/dispatcher/mocks/ITask.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 73 additions & 0 deletions internal/dispatcher/mocks/ITaskActions.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading