Skip to content

Commit c118963

Browse files
Namespace the assert library for old testing files (#1761)
It looks like some older test files were "unwrapping" the assert package to the current context. I'm changing this because: 1. While it works, sometimes the linter flags this. I'm not sure why. 2. Other testing files don't do this. I want consistency. 3. The testify readme doesn't seem to recommend this approach. I rather follow their examples.
1 parent 29bf8f2 commit c118963

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

checklist/checklist_item_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package checklist
33
import (
44
"testing"
55

6-
. "github.com/stretchr/testify/assert"
6+
"github.com/stretchr/testify/assert"
77
)
88

99
func testChecklistItem() *ChecklistItem {
@@ -20,19 +20,19 @@ func testChecklistItem() *ChecklistItem {
2020

2121
func Test_CheckMark(t *testing.T) {
2222
item := testChecklistItem()
23-
Equal(t, " ", item.CheckMark())
23+
assert.Equal(t, " ", item.CheckMark())
2424

2525
item.Toggle()
26-
Equal(t, "x", item.CheckMark())
26+
assert.Equal(t, "x", item.CheckMark())
2727
}
2828

2929
func Test_Toggle(t *testing.T) {
3030
item := testChecklistItem()
31-
Equal(t, false, item.Checked)
31+
assert.Equal(t, false, item.Checked)
3232

3333
item.Toggle()
34-
Equal(t, true, item.Checked)
34+
assert.Equal(t, true, item.Checked)
3535

3636
item.Toggle()
37-
Equal(t, false, item.Checked)
37+
assert.Equal(t, false, item.Checked)
3838
}

utils/email_addresses_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ package utils
33
import (
44
"testing"
55

6-
. "github.com/stretchr/testify/assert"
6+
"github.com/stretchr/testify/assert"
77
)
88

99
func Test_NameFromEmail(t *testing.T) {
10-
Equal(t, "", NameFromEmail(""))
11-
Equal(t, "Chris Cummer", NameFromEmail("[email protected]"))
10+
assert.Equal(t, "", NameFromEmail(""))
11+
assert.Equal(t, "Chris Cummer", NameFromEmail("[email protected]"))
1212
}
1313

1414
func Test_NamesFromEmails(t *testing.T) {
1515
var result []string
1616

1717
result = NamesFromEmails([]string{})
18-
Equal(t, []string{}, result)
18+
assert.Equal(t, []string{}, result)
1919

2020
result = NamesFromEmails([]string{"[email protected]", "[email protected]"})
21-
Equal(t, []string{"Chris Cummer", "Chriscummer"}, result)
21+
assert.Equal(t, []string{"Chris Cummer", "Chriscummer"}, result)
2222
}

utils/init_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ package utils
33
import (
44
"testing"
55

6-
. "github.com/stretchr/testify/assert"
6+
"github.com/stretchr/testify/assert"
77
)
88

99
func Test_Init(t *testing.T) {
1010
Init("cats", []string{"dogs"})
1111

12-
Equal(t, OpenFileUtil, "cats")
13-
Equal(t, OpenUrlUtil, []string{"dogs"})
12+
assert.Equal(t, OpenFileUtil, "cats")
13+
assert.Equal(t, OpenUrlUtil, []string{"dogs"})
1414
}

0 commit comments

Comments
 (0)