Skip to content

Commit

Permalink
[Dembo] Add slack client integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
walbertus committed Sep 18, 2019
1 parent c0ebbf3 commit 332f2c7
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions plugins/slack-notification-plugin/slack/client_integration_test.go
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)
}

0 comments on commit 332f2c7

Please sign in to comment.