-
Notifications
You must be signed in to change notification settings - Fork 0
/
render_test.go
51 lines (46 loc) · 1.25 KB
/
render_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package ezpwd
import (
"bytes"
"testing"
"github.com/stretchr/testify/assert"
)
var pwds = []Password{
{
Service: "Gmail",
Login: "123@123.com",
Password: "password",
},
{
Service: "Yahoo",
Login: "123@yahoo.com",
Password: "nopassword",
},
}
func TestRenderNoPassword(t *testing.T) {
expected := `+---+---------+---------------+---------+
| # | SERVICE | LOGIN | COMMENT |
+---+---------+---------------+---------+
| 0 | Gmail | 123@123.com | |
| 1 | Yahoo | 123@yahoo.com | |
+---+---------+---------------+---------+
`
w := bytes.Buffer{}
pwdWriter := NewHiddenPWDs(&w)
pwdWriter.RenderPasswords(pwds)
content := string(w.Bytes())
assert.Equal(t, expected, content)
}
func TestRenderAllPassword(t *testing.T) {
expected := `+---+---------+---------------+------------+---------+
| # | SERVICE | LOGIN | PASSWORD | COMMENT |
+---+---------+---------------+------------+---------+
| 0 | Gmail | 123@123.com | password | |
| 1 | Yahoo | 123@yahoo.com | nopassword | |
+---+---------+---------------+------------+---------+
`
w := bytes.Buffer{}
pwdWriter := NewShownPWDs(&w)
pwdWriter.RenderPasswords(pwds)
content := string(w.Bytes())
assert.Equal(t, expected, content)
}