This repository has been archived on 2021-09-07. You can view files and clone it, but cannot push or open issues or pull requests.

42 lines
984 B
Go
Raw Normal View History

2018-01-02 22:08:52 +03:00
package factory
import (
"strings"
"testing"
)
func TestGetSMSNotifier(t *testing.T) {
notification := Notification{"5552233", "Hello world!"}
notifier, err := GetNotifier(SMS)
if err != nil {
t.Fatal("Notifier type 'SMS' must be returned")
}
resultStr := notifier.SendNotification(notification)
if !strings.Contains(resultStr, "was sent to number") {
t.Error("SMS notifier result message was not correct.")
}
}
func TestGetEmailNotifier(t *testing.T) {
notification := Notification{"5552233", "Hello world!"}
notifier, err := GetNotifier(Email)
if err != nil {
t.Fatal("Notifier type 'Email' must be returned")
}
resultStr := notifier.SendNotification(notification)
if !strings.Contains(resultStr, "was sent to email") {
t.Error("Email notifier result message was not correct.")
}
}
func TestGetNonExistanceNotifier(t *testing.T) {
_, err := GetNotifier(3)
if err == nil {
t.Fatal("Error must be returned for unrecognized notifier type.")
}
}