-
Notifications
You must be signed in to change notification settings - Fork 1
/
types_test.go
51 lines (40 loc) · 1.11 KB
/
types_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 envsecret_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/gavincabbage/envsecret"
)
func TestPrivateKey_Decode(t *testing.T) {
var (
encodedTestPublicKey = map[string]interface{}{
"public_key": testPrivateKey,
}
encodedJunk = map[string]interface{}{
"public_key": "c29tZWp1bmsK",
}
incorrectlyEncodedJunk = map[string]interface{}{
"public_key": "c29tZWp1bms!!K",
}
)
subject := &envsecret.PrivateKey{}
assert.NoError(t, subject.Decode(encodedTestPublicKey))
assert.Error(t, subject.Decode(encodedJunk))
assert.Error(t, subject.Decode(incorrectlyEncodedJunk))
}
func TestPublicKey_Decode(t *testing.T) {
var (
encodedTestPublicKey = map[string]interface{}{
"public_key": testPublicKey,
}
encodedJunk = map[string]interface{}{
"public_key": "c29tZWp1bmsK",
}
incorrectlyEncodedJunk = map[string]interface{}{
"public_key": "c29tZWp1bms!!K",
}
)
subject := &envsecret.PublicKey{}
assert.NoError(t, subject.Decode(encodedTestPublicKey))
assert.Error(t, subject.Decode(encodedJunk))
assert.Error(t, subject.Decode(incorrectlyEncodedJunk))
}