Skip to content

Commit

Permalink
Merge pull request #76 from opsgenie/int-action-imp-ignore
Browse files Browse the repository at this point in the history
add ignore to integration actions
  • Loading branch information
ilteristabak authored Dec 24, 2020
2 parents 4951c0d + dd5eb32 commit 0158913
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
15 changes: 9 additions & 6 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,14 @@ func TestResponders_Validate(t *testing.T) {
{Type: "Cem"},
}
err = validateResponders(responders)
assert.Equal(t, err.Error(), errors.New("Responder type should be one of these: " +
assert.Equal(t, err.Error(), errors.New("Responder type should be one of these: "+
"'User', 'Team', 'Schedule', 'Escalation'").Error())

responders = []Responder{
{Type: User},
}
err = validateResponders(responders)
assert.Equal(t, err.Error(), errors.New("For responder type user either" +
assert.Equal(t, err.Error(), errors.New("For responder type user either"+
" username or id must be provided.").Error())

responders = []Responder{
Expand All @@ -230,7 +230,7 @@ func TestResponders_Validate(t *testing.T) {
Type: Team},
}
err = validateResponders(responders)
assert.Equal(t, err.Error(), errors.New("For responder type team either team" +
assert.Equal(t, err.Error(), errors.New("For responder type team either team"+
" name or id must be provided.").Error())

responders = []Responder{
Expand All @@ -248,7 +248,7 @@ func TestResponders_Validate(t *testing.T) {
},
}
err = validateResponders(responders)
assert.Equal(t, err.Error(), errors.New("For responder type schedule either schedule" +
assert.Equal(t, err.Error(), errors.New("For responder type schedule either schedule"+
" name or id must be provided.").Error())

responders = []Responder{
Expand All @@ -266,7 +266,7 @@ func TestResponders_Validate(t *testing.T) {
},
}
err = validateResponders(responders)
assert.Equal(t, err.Error(), errors.New("For responder type escalation either escalation" +
assert.Equal(t, err.Error(), errors.New("For responder type escalation either escalation"+
" name or id must be provided.").Error())

responders = []Responder{
Expand All @@ -282,7 +282,7 @@ func TestResponders_Validate(t *testing.T) {
func TestActionType_Validate(t *testing.T) {
err := validateActionType("cem")
assert.Equal(t, err.Error(), errors.New("Action type should be one of these: "+
"'Create','Close','Acknowledge','AddNote'").Error())
"'Create','Close','Acknowledge','AddNote','Ignore'").Error())

err = validateActionType(Create)
assert.Nil(t, err)
Expand All @@ -295,6 +295,9 @@ func TestActionType_Validate(t *testing.T) {

err = validateActionType(AddNote)
assert.Nil(t, err)

err = validateActionType(Ignore)
assert.Nil(t, err)
}

func TestConditionMatchType_Validate(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions integration/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ type UpdateAllIntegrationActionsRequest struct {
Close []IntegrationAction `json:"close"`
Acknowledge []IntegrationAction `json:"acknowledge"`
AddNote []IntegrationAction `json:"addNote"`
Ignore []IntegrationAction `json:"ignore"`
}

type IntegrationAction struct {
Expand Down Expand Up @@ -474,11 +475,11 @@ func validateResponders(responders []Responder) error {

func validateActionType(actionType ActionType) error {
switch actionType {
case Create, Close, Acknowledge, AddNote:
case Create, Close, Acknowledge, AddNote, Ignore:
return nil
}
return errors.New("Action type should be one of these: " +
"'Create','Close','Acknowledge','AddNote'")
"'Create','Close','Acknowledge','AddNote','Ignore'")
}

func validateConditionMatchType(matchType og.ConditionMatchType) error {
Expand Down
1 change: 1 addition & 0 deletions integration/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ const (
Close ActionType = "close"
Acknowledge ActionType = "acknowledge"
AddNote ActionType = "AddNote"
Ignore ActionType = "ignore"
)

type Responder struct {
Expand Down

0 comments on commit 0158913

Please sign in to comment.