github.com/vchain-us/vcn@v0.9.11-0.20210921212052-a2484d23c0b3/pkg/api/sign_options_test.go (about) 1 /* 2 * Copyright (c) 2018-2020 vChain, Inc. All Rights Reserved. 3 * This software is released under GPL3. 4 * The full license information can be found under: 5 * https://www.gnu.org/licenses/gpl-3.0.en.html 6 * 7 */ 8 9 package api 10 11 import ( 12 "testing" 13 14 "github.com/vchain-us/vcn/pkg/meta" 15 16 "github.com/stretchr/testify/assert" 17 ) 18 19 func testUser() User { 20 return *NewUser("example@example.net") 21 } 22 23 func TestMakeSignOpts(t *testing.T) { 24 reader := "Hi!" 25 pass := "word" 26 o, err := makeSignOpts( 27 SignWithKey(reader, pass), 28 ) 29 assert.NoError(t, err) 30 31 assert.Equal(t, reader, o.keyin) 32 assert.Equal(t, pass, o.passphrase) 33 34 // test defaults 35 assert.Equal(t, meta.StatusTrusted, o.status) 36 assert.Equal(t, meta.VisibilityPrivate, o.visibility) 37 } 38 39 func TestSignWithStatus(t *testing.T) { 40 o := &signOpts{} 41 SignWithStatus(meta.StatusUnsupported)(o) 42 43 assert.Equal(t, meta.StatusUnsupported, o.status) 44 } 45 46 func TestSignWithVisibility(t *testing.T) { 47 o := &signOpts{} 48 SignWithVisibility(meta.VisibilityPublic)(o) 49 50 assert.Equal(t, meta.VisibilityPublic, o.visibility) 51 } 52 53 func TestSignWithKey(t *testing.T) { 54 reader := "Hi!" 55 pass := "word" 56 57 o := &signOpts{} 58 SignWithKey(reader, pass)(o) 59 60 assert.Equal(t, reader, o.keyin) 61 assert.Equal(t, pass, o.passphrase) 62 }