Commit b4b3f6a0 by Matheus Alcantara Committed by GitHub

Test: Create unit test to SplitEmails (#27985)

parent a28a2fba
package util
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestSplitEmails(t *testing.T) {
testcases := []struct {
input string
expected []string
}{
{
input: "",
expected: []string{},
},
{
input: "ops@grafana.org",
expected: []string{"ops@grafana.org"},
},
{
input: "ops@grafana.org;dev@grafana.org",
expected: []string{"ops@grafana.org", "dev@grafana.org"},
},
{
input: "ops@grafana.org;dev@grafana.org,",
expected: []string{"ops@grafana.org", "dev@grafana.org"},
},
{
input: "dev@grafana.org,ops@grafana.org",
expected: []string{"dev@grafana.org", "ops@grafana.org"},
},
{
input: "dev@grafana.org,ops@grafana.org,",
expected: []string{"dev@grafana.org", "ops@grafana.org"},
},
{
input: "dev@grafana.org\nops@grafana.org",
expected: []string{"dev@grafana.org", "ops@grafana.org"},
},
{
input: "dev@grafana.org\nops@grafana.org\n",
expected: []string{"dev@grafana.org", "ops@grafana.org"},
},
}
for _, tt := range testcases {
emails := SplitEmails(tt.input)
assert.Equal(t, tt.expected, emails)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment