-
Notifications
You must be signed in to change notification settings - Fork 0
/
password_funcs_test.go
53 lines (39 loc) · 1.49 KB
/
password_funcs_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
52
53
package gokwallet
import (
"testing"
)
// TestPassword tests all functions of a Password.
func TestPassword(t *testing.T) {
var p *Password
var e *testEnv
var err error
if e, err = getTestEnv(t); err != nil {
t.Fatalf("failure getting test env: %v", err)
}
defer e.cleanup(t)
if p, err = NewPassword(e.f, passwordTest.String(), e.r); err != nil {
t.Fatalf("failure getting Password: %v", err)
}
t.Logf("created Password '%v:%v:%v'; initialized: %v", e.w.Name, e.f.Name, p.Name, p.isInit)
if err = p.SetValue(testPassword); err != nil {
t.Errorf("failed to set value for Password '%v:%v:%v': %v", e.w.Name, e.f.Name, p.Name, err)
}
if p.Value != testPassword {
t.Errorf("value '%#v' does not match expected value '%#v'", p.Value, testPassword)
} else {
t.Logf("value for Password '%v:%v:%v': %#v", e.w.Name, e.f.Name, p.Name, p.Value)
}
if err = p.SetValue(testPasswordReplace); err != nil {
t.Errorf("failed to set replacement value for Password '%v:%v:%v': %v", e.w.Name, e.f.Name, p.Name, err)
}
if err = p.Update(); err != nil {
t.Errorf("failed to update Password '%v:%v:%v': %v", e.w.Name, e.f.Name, p.Name, err)
}
t.Logf("replacement value for Password '%v:%v:%v': %v", e.w.Name, e.f.Name, p.Name, p.Value)
if p.Value != testPasswordReplace {
t.Errorf("value '%#v' does not match expected value '%#v'", p.Value, testPasswordReplace)
}
if err = p.Delete(); err != nil {
t.Errorf("failed to delete Password '%v:%v:%v': %v", e.w.Name, e.f.Name, p.Name, err)
}
}