github.com/kiali/kiali@v1.84.0/graph/telemetry/istio/appender/outsider_test.go (about)

     1  package appender
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/require"
     8  
     9  	"github.com/kiali/kiali/config"
    10  	"github.com/kiali/kiali/graph"
    11  )
    12  
    13  func TestOutsider(t *testing.T) {
    14  	require := require.New(t)
    15  
    16  	trafficMap := graph.NewTrafficMap()
    17  
    18  	inaccessible, _ := graph.NewNode(config.DefaultClusterID, "inaccessibleNamespace", "test", "inaccessibleNamespace", "test-v1", "test", "v1", graph.GraphTypeVersionedApp)
    19  	trafficMap[inaccessible.ID] = inaccessible
    20  
    21  	accessible, _ := graph.NewNode(config.DefaultClusterID, "accessibleNamespace", "test", "accessibleNamespace", "test-v1", "test", "v1", graph.GraphTypeVersionedApp)
    22  	trafficMap[accessible.ID] = accessible
    23  
    24  	globalInfo := graph.NewAppenderGlobalInfo()
    25  	namespaceInfo := graph.NewAppenderNamespaceInfo("testNamespace")
    26  
    27  	a := OutsiderAppender{
    28  		AccessibleNamespaces: map[string]*graph.AccessibleNamespace{
    29  			fmt.Sprintf("%s:accessibleNamespace", config.DefaultClusterID): {
    30  				Name:    "accessibleNamespace",
    31  				Cluster: config.DefaultClusterID,
    32  			},
    33  		},
    34  	}
    35  	a.AppendGraph(trafficMap, globalInfo, namespaceInfo)
    36  
    37  	require.Equal(true, trafficMap[inaccessible.ID].Metadata[graph.IsInaccessible])
    38  	require.Equal(nil, trafficMap[accessible.ID].Metadata[graph.IsInaccessible])
    39  }