-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ecd9ac7
commit 309cfa5
Showing
4 changed files
with
22 additions
and
21 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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package pagerduty_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
gopagerduty "github.com/PagerDuty/go-pagerduty" | ||
|
@@ -23,13 +22,13 @@ func TestConfig_NewConfig(t *testing.T) { | |
require.Equal(t, want, config) | ||
} | ||
|
||
func TestConfig_OK(t *testing.T) { | ||
func TestConfig_OK(t *testing.T) { //nolint:funlen | ||
t.Parallel() | ||
|
||
tests := []struct { | ||
name string | ||
config *pagerduty.Config | ||
wantErr error | ||
wantErr string | ||
}{ | ||
{ | ||
name: "ok_basic_config", | ||
|
@@ -38,7 +37,7 @@ func TestConfig_OK(t *testing.T) { | |
Receivers: []string{"AB1234", "CD5678"}, | ||
NotificationType: "incident", | ||
}, | ||
wantErr: nil, | ||
wantErr: "", | ||
}, | ||
{ | ||
name: "ok_complete_config", | ||
|
@@ -49,37 +48,37 @@ func TestConfig_OK(t *testing.T) { | |
PriorityID: "P1234", | ||
NotificationType: "incident", | ||
}, | ||
wantErr: nil, | ||
wantErr: "", | ||
}, | ||
{ | ||
name: "missing_from_address", | ||
config: &pagerduty.Config{ | ||
Receivers: []string{"AB1234", "CD5678"}, | ||
}, | ||
wantErr: fmt.Errorf("from address is required"), | ||
wantErr: "from address is required", | ||
}, | ||
{ | ||
name: "invalid_from_address", | ||
config: &pagerduty.Config{ | ||
FromAddress: "senderdomain.com", | ||
Receivers: []string{"AB1234", "CD5678"}, | ||
}, | ||
wantErr: fmt.Errorf("from address is invalid: mail: missing '@' or angle-addr"), | ||
wantErr: "from address is invalid: mail: missing '@' or angle-addr", | ||
}, | ||
{ | ||
name: "missing_receivers", | ||
config: &pagerduty.Config{ | ||
FromAddress: "[email protected]", | ||
}, | ||
wantErr: fmt.Errorf("at least one receiver is required"), | ||
wantErr: "at least one receiver is required", | ||
}, | ||
{ | ||
name: "missing_notification_type", | ||
config: &pagerduty.Config{ | ||
FromAddress: "[email protected]", | ||
Receivers: []string{"AB1234", "CD5678"}, | ||
}, | ||
wantErr: fmt.Errorf("notification type is required"), | ||
wantErr: "notification type is required", | ||
}, | ||
} | ||
|
||
|
@@ -88,12 +87,12 @@ func TestConfig_OK(t *testing.T) { | |
t.Parallel() | ||
|
||
err := test.config.OK() | ||
if test.wantErr == nil { | ||
if test.wantErr == "" { | ||
require.NoError(t, err) | ||
return | ||
} | ||
|
||
require.EqualError(t, err, test.wantErr.Error()) | ||
require.EqualError(t, err, test.wantErr) | ||
}) | ||
} | ||
} | ||
|
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ package pagerduty_test | |
|
||
import ( | ||
"context" | ||
"fmt" | ||
"errors" | ||
"testing" | ||
|
||
gopagerduty "github.com/PagerDuty/go-pagerduty" | ||
|
@@ -29,7 +29,7 @@ func (m *mockClient) CreateIncidentWithContext( | |
|
||
incident, isIncident := args.Get(0).(*gopagerduty.Incident) | ||
if !isIncident { | ||
return nil, fmt.Errorf("unexpected type for first argument") | ||
return nil, errors.New("unexpected type for first argument") | ||
} | ||
|
||
return incident, nil | ||
|
@@ -49,7 +49,7 @@ func TestPagerDuty_New(t *testing.T) { | |
assert.Equal(t, want, service) | ||
} | ||
|
||
func TestPagerDuty_Send(t *testing.T) { | ||
func TestPagerDuty_Send(t *testing.T) { //nolint:funlen | ||
t.Parallel() | ||
|
||
tests := []struct { | ||
|
@@ -89,7 +89,7 @@ func TestPagerDuty_Send(t *testing.T) { | |
message: "Test Message", | ||
mockSetup: func(m *mockClient) { | ||
m.On("CreateIncidentWithContext", mock.Anything, "[email protected]", mock.Anything). | ||
Return(nil, fmt.Errorf("invalid configuration: at least one receiver is required")) | ||
Return(nil, errors.New("invalid configuration: at least one receiver is required")) | ||
}, | ||
expectedError: "invalid configuration: at least one receiver is required", | ||
}, | ||
|