Skip to content

Commit 5bd68c8

Browse files
committed
[FAB-3441] bccsp/sw/dummyks.go test coverage
This change-set improves the test coverage of bccsp/sw/dummyks.go to 100% Change-Id: Ib4b2fc8c3e3e598404f9d5a7a5cd9cdc8855f45d Signed-off-by: Angelo De Caro <[email protected]>
1 parent ca3a1a2 commit 5bd68c8

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

bccsp/mocks/mocks.go

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
Copyright IBM Corp. 2017 All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package mocks
18+
19+
import "github.com/hyperledger/fabric/bccsp"
20+
21+
type MockKey struct{}
22+
23+
func (*MockKey) Bytes() ([]byte, error) {
24+
panic("implement me")
25+
}
26+
27+
func (*MockKey) SKI() []byte {
28+
panic("implement me")
29+
}
30+
31+
func (*MockKey) Symmetric() bool {
32+
panic("implement me")
33+
}
34+
35+
func (*MockKey) Private() bool {
36+
panic("implement me")
37+
}
38+
39+
func (*MockKey) PublicKey() (bccsp.Key, error) {
40+
panic("implement me")
41+
}

bccsp/sw/dummyks_test.go

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
Copyright IBM Corp. 2017 All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
package sw
17+
18+
import (
19+
"testing"
20+
21+
"github.com/hyperledger/fabric/bccsp/mocks"
22+
"github.com/stretchr/testify/assert"
23+
)
24+
25+
func TestNewDummyKeyStore(t *testing.T) {
26+
ks := NewDummyKeyStore()
27+
assert.NotNil(t, ks)
28+
}
29+
30+
func TestDummyKeyStore_GetKey(t *testing.T) {
31+
ks := NewDummyKeyStore()
32+
_, err := ks.GetKey([]byte{0, 1, 2, 3, 4})
33+
assert.Error(t, err)
34+
}
35+
36+
func TestDummyKeyStore_ReadOnly(t *testing.T) {
37+
ks := NewDummyKeyStore()
38+
assert.True(t, ks.ReadOnly())
39+
}
40+
41+
func TestDummyKeyStore_StoreKey(t *testing.T) {
42+
ks := NewDummyKeyStore()
43+
err := ks.StoreKey(&mocks.MockKey{})
44+
assert.Error(t, err)
45+
}

0 commit comments

Comments
 (0)