Skip to content

Commit

Permalink
[FAB-3441] bccsp/sw/dummyks.go test coverage
Browse files Browse the repository at this point in the history
This change-set improves the test coverage
of bccsp/sw/dummyks.go to 100%

Change-Id: Ib4b2fc8c3e3e598404f9d5a7a5cd9cdc8855f45d
Signed-off-by: Angelo De Caro <adc@zurich.ibm.com>
  • Loading branch information
adecaro committed Apr 27, 2017
1 parent ca3a1a2 commit 5bd68c8
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 5bd68c8

Please sign in to comment.