-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
gopass_test.go
42 lines (36 loc) · 924 Bytes
/
gopass_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
package main
import (
"errors"
"testing"
"github.com/stretchr/testify/require"
)
func Test_gopassGetterOK(t *testing.T) {
defaultGopassGet = func(itemName string) (string, error) {
return "foo", nil
}
v, e := gopassGetter("something")
require.Equal(t, "foo", v)
require.Nil(t, e)
}
func Test_gopassGetterERROR(t *testing.T) {
defaultGopassGet = func(itemName string) (string, error) {
return "bar", errors.New("foobar")
}
v, e := gopassGetter("something")
require.Equal(t, "foobar", e.Error())
require.Equal(t, "bar", v)
}
func Test_gopassSetterOK(t *testing.T) {
defaultGopassSet = func(itemName, secret string) error {
return nil
}
e := gopassSetter("foo", "bar")
require.Nil(t, e)
}
func Test_gopassSetterERROR(t *testing.T) {
defaultGopassSet = func(itemName, secret string) error {
return errors.New("foofoo")
}
e := gopassSetter("foo", "bar")
require.Equal(t, "foofoo", e.Error())
}