Review: Using testify. Renamed var.
This commit is contained in:
@@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user