Skip to content

Commit

Permalink
Merge "[FAB-3441] bccsp/sw/dummyks.go test coverage"
Browse files Browse the repository at this point in the history
  • Loading branch information
binhn authored and Gerrit Code Review committed Apr 28, 2017
2 parents 87cb78e + 5bd68c8 commit 23866ec
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
41 changes: 41 additions & 0 deletions bccsp/mocks/mocks.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
Copyright IBM Corp. 2017 All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package mocks

import "github.com/hyperledger/fabric/bccsp"

type MockKey struct{}

func (*MockKey) Bytes() ([]byte, error) {
panic("implement me")
}

func (*MockKey) SKI() []byte {
panic("implement me")
}

func (*MockKey) Symmetric() bool {
panic("implement me")
}

func (*MockKey) Private() bool {
panic("implement me")
}

func (*MockKey) PublicKey() (bccsp.Key, error) {
panic("implement me")
}
45 changes: 45 additions & 0 deletions bccsp/sw/dummyks_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
Copyright IBM Corp. 2017 All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package sw

import (
"testing"

"github.com/hyperledger/fabric/bccsp/mocks"
"github.com/stretchr/testify/assert"
)

func TestNewDummyKeyStore(t *testing.T) {
ks := NewDummyKeyStore()
assert.NotNil(t, ks)
}

func TestDummyKeyStore_GetKey(t *testing.T) {
ks := NewDummyKeyStore()
_, err := ks.GetKey([]byte{0, 1, 2, 3, 4})
assert.Error(t, err)
}

func TestDummyKeyStore_ReadOnly(t *testing.T) {
ks := NewDummyKeyStore()
assert.True(t, ks.ReadOnly())
}

func TestDummyKeyStore_StoreKey(t *testing.T) {
ks := NewDummyKeyStore()
err := ks.StoreKey(&mocks.MockKey{})
assert.Error(t, err)
}

0 comments on commit 23866ec

Please sign in to comment.