Review: Using testify. Renamed var.

This commit is contained in:
Patrick Connolly
2018-11-20 21:14:56 +08:00
parent 2a47b8fd40
commit 31e2edf089

View File

@@ -2,13 +2,15 @@ package bslack
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestExtractTopicOrPurpose(t *testing.T) {
tables := []struct{
testcases := []struct{
input string
changeType string
output string
wantChangeType string
wantOutput string
}{
{"@someone set channel topic: one liner", "topic", "one liner"},
{"@someone set channel purpose: one liner", "purpose", "one liner"},
@@ -17,10 +19,10 @@ func TestExtractTopicOrPurpose(t *testing.T) {
{"some unmatched message", "unknown", ""},
}
for _, table := range tables {
changeType, output := extractTopicOrPurpose(table.input)
if changeType != table.changeType || output != table.output {
t.Error()
}
for _, tc := range testcases {
gotChangeType, gotOutput := extractTopicOrPurpose(tc.input)
assert.Equal(t, tc.wantChangeType , gotChangeType)
assert.Equal(t, tc.wantOutput , gotOutput)
}
}