2014-04-18 01:57:13 +03:00
|
|
|
package notify
|
|
|
|
|
2014-10-23 08:26:14 +03:00
|
|
|
import "testing"
|
|
|
|
|
|
|
|
/*
|
|
|
|
var request = &model.Request{
|
|
|
|
Host: "http://examplehost.com",
|
|
|
|
Repo: &model.Repo{
|
|
|
|
Host: "examplegit.com",
|
|
|
|
Owner: "owner",
|
|
|
|
Name: "repo",
|
|
|
|
},
|
|
|
|
Commit: &model.Commit{
|
|
|
|
Sha: "abc",
|
|
|
|
Branch: "example",
|
|
|
|
Status: "Started",
|
|
|
|
Message: "Test Commit",
|
|
|
|
Author: "Test User",
|
|
|
|
},
|
|
|
|
User: &model.User{
|
|
|
|
Login: "TestUser",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
var slackExpectedLink = "<owner/repo#abc|http://examplehost.com/examplegit.com/owner/repo/example/abc>"
|
|
|
|
var slackExpectedBase = slackExpectedLink + " (example) by Test User"
|
|
|
|
|
|
|
|
func Test_slackStartedMessage(t *testing.T) {
|
|
|
|
actual := (&Slack{}).getMessage(request, slackStartedMessage)
|
|
|
|
|
|
|
|
expected := "*Building* " + slackExpectedBase
|
|
|
|
|
|
|
|
if actual != expected {
|
|
|
|
t.Errorf("Invalid getStarted message for Slack. Expected %v, got %v", expected, actual)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func Test_slackSuccessMessage(t *testing.T) {
|
|
|
|
actual := (&Slack{}).getMessage(request, slackSuccessMessage)
|
|
|
|
|
|
|
|
expected := "*Success* " + slackExpectedBase
|
|
|
|
|
|
|
|
if actual != expected {
|
|
|
|
t.Errorf("Invalid getStarted message for Slack. Expected %v, got %v", expected, actual)
|
2014-04-18 01:57:13 +03:00
|
|
|
}
|
2014-10-23 08:26:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func Test_slackFailureMessage(t *testing.T) {
|
|
|
|
actual := (&Slack{}).getMessage(request, slackFailureMessage)
|
|
|
|
|
|
|
|
expected := "*Failed* " + slackExpectedBase
|
2014-04-18 01:57:13 +03:00
|
|
|
|
2014-10-23 08:26:14 +03:00
|
|
|
if actual != expected {
|
|
|
|
t.Errorf("Invalid getStarted message for Slack. Expected %v, got %v", expected, actual)
|
2014-04-18 01:57:13 +03:00
|
|
|
}
|
|
|
|
}
|