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