github.com/hyperledger/aries-framework-go@v0.3.2/pkg/didcomm/common/service/messenger_test.go (about)

     1  /*
     2  Copyright SecureKey Technologies Inc. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package service_test
     8  
     9  import (
    10  	"testing"
    11  
    12  	"github.com/google/uuid"
    13  	"github.com/stretchr/testify/require"
    14  
    15  	"github.com/hyperledger/aries-framework-go/pkg/didcomm/common/service"
    16  )
    17  
    18  func TestNewDIDCommContext(t *testing.T) {
    19  	t.Run("returns DIDs and properties", func(t *testing.T) {
    20  		myDID := uuid.New().String()
    21  		theirDID := uuid.New().String()
    22  		propKey := uuid.New().String()
    23  		propValue := uuid.New().String()
    24  
    25  		c := service.NewDIDCommContext(myDID, theirDID, map[string]interface{}{
    26  			propKey: propValue,
    27  		})
    28  		require.NotNil(t, c)
    29  
    30  		require.Equal(t, myDID, c.MyDID())
    31  		require.Equal(t, theirDID, c.TheirDID())
    32  		p, ok := c.All()[propKey].(string)
    33  		require.True(t, ok)
    34  		require.Equal(t, propValue, p)
    35  	})
    36  }
    37  
    38  func TestEmptyDIDCommContext(t *testing.T) {
    39  	t.Run("returns an empty context", func(t *testing.T) {
    40  		c := service.EmptyDIDCommContext()
    41  		require.NotNil(t, c)
    42  		require.Empty(t, c.MyDID())
    43  		require.Empty(t, c.TheirDID())
    44  		require.Empty(t, c.All())
    45  	})
    46  }