github.com/hyperledger/aries-framework-go@v0.3.2/pkg/framework/aries/default_test.go (about) 1 /* 2 Copyright SecureKey Technologies Inc. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package aries 8 9 import ( 10 "errors" 11 "testing" 12 13 "github.com/golang/mock/gomock" 14 "github.com/stretchr/testify/require" 15 16 mocks "github.com/hyperledger/aries-framework-go/pkg/internal/gomocks/spi/storage" 17 verifiableStoreMocks "github.com/hyperledger/aries-framework-go/pkg/internal/gomocks/store/verifiable" 18 ) 19 20 func TestDefaultFramework(t *testing.T) { 21 ctrl := gomock.NewController(t) 22 defer ctrl.Finish() 23 24 t.Run("test default framework - success", func(t *testing.T) { 25 aries := &Aries{} 26 err := defFrameworkOpts(aries) 27 require.NoError(t, err) 28 }) 29 30 t.Run("test with provided store - success", func(t *testing.T) { 31 mockStore := verifiableStoreMocks.NewMockStore(ctrl) 32 aries := &Aries{verifiableStore: mockStore} 33 err := defFrameworkOpts(aries) 34 require.NoError(t, err) 35 require.Equal(t, mockStore, aries.verifiableStore) 36 }) 37 } 38 39 func TestCreateVerifiableStore(t *testing.T) { 40 ctrl := gomock.NewController(t) 41 defer ctrl.Finish() 42 43 t.Run("test with store provider - error", func(t *testing.T) { 44 storeProvider := mocks.NewMockProvider(ctrl) 45 storeProvider.EXPECT().OpenStore(gomock.Any()).Return(nil, errors.New("some error")) 46 err := assignVerifiableStoreIfNeeded(&Aries{}, storeProvider) 47 require.Error(t, err) 48 }) 49 }