Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
Signed-off-by: Alessio Treglia <al@essio.dev>
  • Loading branch information
alessio committed Sep 12, 2024
1 parent 900a7a1 commit 434b5f2
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions crypto/keyring/keyring_linux_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//go:build linux
// +build linux

package keyring

import (
"errors"
"io"
"strings"
"testing"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/stretchr/testify/require"
)

func TestNewKeyctlKeyring(t *testing.T) {
cdc := getCodec()

tests := []struct {
name string
appName string
backend string
dir string
userInput io.Reader
cdc codec.Codec
expectedErr error
}{
{
name: "keyctl backend",
appName: "cosmos",
backend: BackendKeyctl,
dir: t.TempDir(),
userInput: strings.NewReader(""),
cdc: cdc,
expectedErr: nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
kr, err := New(tt.appName, tt.backend, tt.dir, tt.userInput, tt.cdc)
if tt.expectedErr == nil {
require.NoError(t, err)
} else {
require.Error(t, err)
require.Nil(t, kr)
require.True(t, errors.Is(err, tt.expectedErr))
}
})
}
}

0 comments on commit 434b5f2

Please sign in to comment.