-
Notifications
You must be signed in to change notification settings - Fork 0
/
gop_test.go
43 lines (39 loc) · 1.13 KB
/
gop_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
package main
import (
"bytes"
"reflect"
"testing"
)
func TestEntryParsing(t *testing.T) {
json := []byte(`{
"uuid":"ignored",
"vaultUuid":"ignored",
"overview":{
"title":"value for op get item"
},
"details":{
"fields":[
],
"sections":[
{
"title":"Credentials",
"name":"Section_ignored",
"fields":[
{"k":"string","n":"ignored","t":"access","v":"access_value"},
{"k":"concealed","n":"ignored","t":"secret","v":"secret_value"},
{"k":"string","n":"ignored","t":"region","v":"region_value"}
]
}
]
}
}`)
lines := parse1PasswordEntry(bytes.NewBuffer(json))
expectedLines := []string{
"export AWS_ACCESS_KEY_ID='access_value'",
"export AWS_SECRET_ACCESS_KEY='secret_value'",
"export AWS_DEFAULT_REGION='region_value'",
}
if !reflect.DeepEqual(lines, expectedLines) {
t.Errorf("Actual output %v does not equal expected %v", lines, expectedLines)
}
}