github.com/yacovm/fabric@v2.0.0-alpha.0.20191128145320-c5d4087dc723+incompatible/common/graph/graph_test.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package graph
     8  
     9  import (
    10  	"testing"
    11  
    12  	"github.com/stretchr/testify/assert"
    13  )
    14  
    15  func TestVertex(t *testing.T) {
    16  	v := NewVertex("1", "1")
    17  	assert.Equal(t, "1", v.Data)
    18  	assert.Equal(t, "1", v.Id)
    19  	u := NewVertex("2", "2")
    20  	v.AddNeighbor(u)
    21  	assert.Contains(t, u.Neighbors(), v)
    22  	assert.Contains(t, v.Neighbors(), u)
    23  	assert.Equal(t, u, v.NeighborById("2"))
    24  	assert.Nil(t, v.NeighborById("3"))
    25  }