forked from gojek/proctor
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Dembo] Add slack client integration test
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
plugins/slack-notification-plugin/slack/client_integration_test.go
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,53 @@ | ||
package slack | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/go-resty/resty/v2" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
type integrationContext interface { | ||
setUp(t *testing.T) | ||
tearDown() | ||
instance() *integrationTestContext | ||
} | ||
|
||
type integrationTestContext struct { | ||
slackClient SlackClient | ||
slackUrl string | ||
} | ||
|
||
func (context *integrationTestContext) setUp(t *testing.T) { | ||
value, available := os.LookupEnv("ENABLE_PLUGIN_INTEGRATION_TEST") | ||
if available != true || value != "true" { | ||
t.SkipNow() | ||
} | ||
client := resty.New() | ||
context.slackClient = NewSlackClient(client) | ||
slackUrl, _ := os.LookupEnv("SLACK_PLUGIN_URL") | ||
assert.NotEmpty(t, slackUrl) | ||
context.slackUrl = slackUrl | ||
} | ||
|
||
func (context *integrationTestContext) tearDown() { | ||
} | ||
|
||
func (context *integrationTestContext) instance() *integrationTestContext { | ||
return context | ||
} | ||
|
||
func newIntegrationContext() integrationContext { | ||
return &integrationTestContext{} | ||
} | ||
|
||
func TestSlackClientIntegration_Publish(t *testing.T) { | ||
ctx := newIntegrationContext() | ||
ctx.setUp(t) | ||
defer ctx.tearDown() | ||
|
||
message := NewStandardMessage("Message from slack plugin integration test with standard message") | ||
err := ctx.instance().slackClient.Publish(message) | ||
assert.NoError(t, err) | ||
} |