Skip to content

Commit

Permalink
FAB-17552: add unit test for createKeyStore
Browse files Browse the repository at this point in the history
Signed-off-by: Shitaibin <[email protected]>
Change-Id: I2938ff54e8460ddc46151cdcd539b2eedf2ea449
  • Loading branch information
Shitaibin authored and denyeart committed Apr 19, 2020
1 parent f27803f commit e1db649
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions bccsp/sw/fileks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,29 @@ func TestReInitKeyStore(t *testing.T) {
err = fbKs.Init(nil, ksPath, false)
assert.EqualError(t, err, "KeyStore already initilized.")
}

func TestCreateKeyStoreFailed(t *testing.T) {
tempDir, err := ioutil.TempDir("", "bccspks")
assert.NoError(t, err)
defer os.RemoveAll(tempDir)
validpath := filepath.Join(tempDir, "keystore")

cs := []struct {
valid bool
path string
}{
{false, "/invalid/keystore"},
{true, validpath},
}

for i, c := range cs {
cid := fmt.Sprintf("case %d", i)

_, err := NewFileBasedKeyStore(nil, c.path, false)
if c.valid {
assert.NoError(t, err, cid)
} else {
assert.Error(t, err, cid)
}
}
}

0 comments on commit e1db649

Please sign in to comment.