test

package
v0.46.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2024 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Overview

Package test contains helper functions for unit testing.

Index

Constants

This section is empty.

Variables

View Source
var (
	Resource1 = []*authorizationpb.IsAuthorizedRequest_Resource{
		{
			ExternalId: "pFlpMtkWqCPXVue",
			Type:       "Asset",
			Actions:    []string{"SUBSCRIBES_TO"},
		},
	}

	Resource2 = []*authorizationpb.IsAuthorizedRequest_Resource{
		{
			ExternalId: "pFlpMtkWqCPXVue",
			Actions:    []string{"SUBSCRIBES_TO"},
		},
	}

	Resource3 = []*authorizationpb.IsAuthorizedRequest_Resource{
		{
			ExternalId: "pFlpMtkWqCPXVue",
			Type:       "Asset",
			Actions:    []string{"DEMANDS"},
		},
	}

	Resource4 = []*authorizationpb.IsAuthorizedRequest_Resource{
		{
			ExternalId: "QovektcrVBbNmFj",
			Type:       "Asset",
			Actions:    []string{"SUBSCRIBES_TO"},
		},
	}

	Resource5 = []*authorizationpb.IsAuthorizedRequest_Resource{
		{
			ExternalId: "HQKzkgPnGJDiaGo",
			Type:       "Asset",
			Actions:    []string{"SUBSCRIBES_TO"},
		},
	}

	Resource6 = []*authorizationpb.IsAuthorizedRequest_Resource{
		{
			ExternalId: "XcbZruEzGNYHLic",
			Type:       "Asset",
			Actions:    []string{"SUBSCRIBES_TO"},
		},
	}

	Resource7 = []*authorizationpb.IsAuthorizedRequest_Resource{
		{
			ExternalId: "zIDegSbXcRlBeFZ",
			Type:       "Asset",
			Actions:    []string{"SUBSCRIBES_TO"},
		},
	}

	Resource8 = []*authorizationpb.IsAuthorizedRequest_Resource{
		{
			ExternalId: "paLtQSpEcTvzeuC",
			Type:       "Asset",
			Actions:    []string{"SUBSCRIBES_TO"},
		},
	}

	Resource9 = []*authorizationpb.IsAuthorizedRequest_Resource{
		{
			ExternalId: "pFlpMtkWqCPXVue",
			Type:       "Asset",
			Actions:    []string{"SUBSCRIBES_TO"},
		},
		{
			ExternalId: "HQKzkgPnGJDiaGo",
			Type:       "Asset",
			Actions:    []string{"SUBSCRIBES_TO"},
		},
	}

	Resource10 = []*authorizationpb.IsAuthorizedRequest_Resource{
		{
			ExternalId: "Truck1",
			Type:       "Truck",
			Actions:    []string{"SUBSCRIBES_TO"},
		},
	}

	Resource11 = []*authorizationpb.IsAuthorizedRequest_Resource{
		{
			ExternalId: "Truck3",
			Type:       "Truck",
			Actions:    []string{"SUBSCRIBES_TO"},
		},
	}

	Resource12 = []*authorizationpb.IsAuthorizedRequest_Resource{
		{
			ExternalId: "Truck4",
			Type:       "Truck",
			Actions:    []string{"SUBSCRIBES_TO"},
		},
	}

	Resource13 = []*authorizationpb.IsAuthorizedRequest_Resource{
		{
			ExternalId: "Truck5",
			Type:       "Truck",
			Actions:    []string{"SUBSCRIBES_TO"},
		},
	}

	Resource14 = []*authorizationpb.IsAuthorizedRequest_Resource{
		{
			ExternalId: "Truck2",
			Type:       "Truck",
			Actions:    []string{"SUBSCRIBES_TO"},
		},
	}

	ResourceType1 = []*authorizationpb.WhatAuthorizedRequest_ResourceType{
		{Type: "Asset", Actions: []string{"SUBSCRIBES_TO"}},
	}

	ResourceType2 = []*authorizationpb.WhatAuthorizedRequest_ResourceType{
		{Actions: []string{"SUBSCRIBES_TO", "OWNS"}},
	}

	ResourceType3 = []*authorizationpb.WhatAuthorizedRequest_ResourceType{
		{Type: "Asset", Actions: []string{"DEMANDS"}},
	}

	ResourceType4 = []*authorizationpb.WhatAuthorizedRequest_ResourceType{
		{Type: "Truck", Actions: []string{"SUBSCRIBES_TO"}},
	}

	ResourceWho1 = []*authorizationpb.WhoAuthorizedRequest_Resource{
		{ExternalId: "pFlpMtkWqCPXVue", Type: "Asset", Actions: []string{"SUBSCRIBES_TO", "OWNS"}},
	}

	ResourceWho2 = []*authorizationpb.WhoAuthorizedRequest_Resource{
		{Type: "Asset", Actions: []string{"SUBSCRIBES_TO", "OWNS"}},
	}

	ResourceWho3 = []*authorizationpb.WhoAuthorizedRequest_Resource{
		{ExternalId: "pFlpMtkWqCPXVue", Type: "Asset", Actions: []string{"DEMANDS", "REPELS"}},
	}

	ResourceWho4 = []*authorizationpb.WhoAuthorizedRequest_Resource{
		{ExternalId: "Truck1", Type: "Truck", Actions: []string{"SUBSCRIBES_TO", "OWNS"}},
	}

	NodeBad     = "id"
	NodeNotInDB = "gid:AAAAGaiIPzg6L0DKkbIh22crsFg"
	Node1       = "gid:AAAAHJsPjaxKk0WchnF4wH3Hg10"
	Node2       = "gid:AAAAHO-ocNjhAU1dlkF_1QG22Uo"
	Node3       = "gid:AAAAHCV9T0p2sU63pJmKD0HZzM8"
	Node4       = "gid:AAAAHH50iSkNRkZni9C12Ed-7fk"
	Node5       = "gid:AAAAHIJg29h5dErYihm_ZRLDB_Y"
	Node6       = "gid:AAAAHD7D1VHJAEBoh0XAcDkvwlY"
	Node7       = "gid:AAAAHBKAf-Hu_04hvTIingK8q5Q"

	EmailBad   = "test@example.com"
	EmailGood  = "biche@yahoo.co.uk"
	EmailGood2 = "darna@yahoo.co.uk"
	EmailWhat  = "banabebe@yahoo.com"

	ExternalIDGood = "TrSFiLuoSLGiCIo"

	Asset1  = "HQKzkgPnGJDiaGo"
	Asset2  = "pFlpMtkWqCPXVue"
	Asset3  = "zojWwtKbBLmAXCO"
	Asset4  = "paLtQSpEcTvzeuC"
	Asset5  = "dLZVTSllFCdZfXC"
	Car1    = "gid:AAAAHMjQZuF-L0F6lliyCVGfIRc"
	Car1Ext = "9658744"
	Car2    = "gid:AAAAHM1Lc0CS5EJxpM5QuRUAnrc"
	Car2Ext = "963258"
	Truck1  = "Truck1"

	Subject1   = "dilZWYdFcmXiojC"
	Subject2   = "fVcaUxJqmOkyOTX"
	Subject3   = "lSPmCXIPRXppszf"
	Subject4   = "NACTFFKUCcceDIz"
	Subject5   = "barnabebe"
	SubjectDT4 = "852147963"
	SubjectDT5 = "741258"

	ConsentConfigID = "gid:AAAAHd5zxpEOlkZtkZQBQ4LEpMg"
	ConsentConfig2  = "gid:AAAAHW5LGqLwe02RgZH6F-p7Tqk"
	ConsentConfig3  = "gid:AAAAHf76WounSEFgg_PZXdvz-eI"
	Application     = "gid:AAAABAm7PCSpUkkej0_iLS8pWrM"
	ConsentInvalid  = "gid:AAAAHXG0xeENcEY6n2qHrf5v7bU"
	ConsentEnforce  = "gid:AAAAHedNk86qM0KHn5KkOWZPSn0"
	ConsentAllow    = "gid:AAAAHfIbn_01-0a9igaJVUOjjg8"

	Resolver = "gid:AAAAIYZfGPsbJEiFnV92GnXklOc"
	URL      = "https://example.com/source2"
	URLUpd   = "https://example.com/sourceupd"
	Method1  = "GET"
	Method2  = "POST"
	Method3  = "ACTION"
	Headers  = map[string]*configpb.ExternalDataResolverConfig_Header{
		"Authorization": {Values: []string{"Bearer edolkUTY"}},
		"Content-Type":  {Values: []string{"application/json"}},
	}
	HeadersUpd = map[string]*configpb.ExternalDataResolverConfig_Header{
		"Authorization": {Values: []string{"Bearer pdnYhjui"}},
		"Content-Type":  {Values: []string{"application/json"}},
	}
	RequestType      = configpb.ExternalDataResolverConfig_CONTENT_TYPE_JSON
	RequestPayload   = []byte(`{"key": "value"}`)
	ResponseType     = configpb.ExternalDataResolverConfig_CONTENT_TYPE_JSON
	ResponseSelector = "."

	CustomerID    = os.Getenv("CUSTOMER_ID")
	WrongAppSpace = "gid:AAAAAgDRZxyY6Ecrjhj2GMCtgVI"
	Tags          = []string{"Sitea", "Siteb"}

	NodeFilter1 = &configpb.EntityMatchingPipelineConfig_NodeFilter{
		SourceNodeTypes: []string{"Customer"},
		TargetNodeTypes: []string{"Client"},
	}
	NodeFilter3 = &configpb.EntityMatchingPipelineConfig_NodeFilter{
		SourceNodeTypes: []string{"Employee"},
	}
)

Functions

func BatchNodesMatch added in v0.30.1

func BatchNodesMatch(
	nodeMatch *ingestpb.NodeMatch, nodeMatch2 *ingestpb.NodeMatch) []*ingestpb.NodeMatch

func BatchNodesType added in v0.30.1

func BatchNodesType(
	typeNode string) ([]*knowledgeobjects.Node, string, string)

func BatchRelationships added in v0.30.1

func BatchRelationships(
	relationship *ingestpb.Relationship, relationship2 *ingestpb.Relationship) []*ingestpb.Relationship

func BeBase64

func BeBase64() types.GomegaMatcher

BeBase64 match string if it is Base64 Standard encoded.

func CreateBatchNodeMatch added in v0.30.1

func CreateBatchNodeMatch(
	externalID string, typeNode string) *ingestpb.NodeMatch

func CreateBatchNodes added in v0.30.1

func CreateBatchNodes(
	typeNode string) (*knowledgeobjects.Node, string)

func CreateBatchNodesError added in v0.39.0

func CreateBatchNodesError(
	typeNode string) *knowledgeobjects.Node

func CreateBatchNodesNoResolver added in v0.39.0

func CreateBatchNodesNoResolver(
	typeNode string) *knowledgeobjects.Node

func CreateRecordNoProperty added in v0.23.0

func CreateRecordNoProperty(externalID, nodeType string) *ingestpb.Record

func CreateRecordNodeIndividual added in v0.23.0

func CreateRecordNodeIndividual(
	role string) (*ingestpb.Record, string)

func CreateRecordRelationship added in v0.23.0

func CreateRecordRelationship(
	sourceExternalID string,
	sourceType string,
	targetExternalID string,
	targetType string,
	relationType string) *ingestpb.Record

func CreateRecordResourceNoProperty added in v0.23.0

func CreateRecordResourceNoProperty(externalID, nodeType string) *ingestpb.Record

func DeleteRecord added in v0.18.0

func DeleteRecord(externalID, nodeType string) *ingestpb.Record

func DeleteRecordRelationship added in v0.23.0

func DeleteRecordRelationship(relationship *ingestpb.Relationship) *ingestpb.Record

func DeleteRecordRelationshipProperty added in v0.23.0

func DeleteRecordRelationshipProperty(
	sourceExternalID string,
	sourceType string,
	targetExternalID string,
	targetType string,
	typeRelation string,
	propertyType string) *ingestpb.Record

func DeleteRecordWithProperty added in v0.23.0

func DeleteRecordWithProperty(externalID, nodeType, property string) *ingestpb.Record

func EqualAnyProto

func EqualAnyProto(expected protoreflect.ProtoMessage) types.GomegaMatcher

EqualAnyProto uses proto.Equal to compare actual with expected. Equal is strict about types when performing comparisons. It is an error for both actual and expected to be nil. Use BeNil() instead.

func EqualProto

func EqualProto(expected protoreflect.ProtoMessage) types.GomegaMatcher

EqualProto uses proto.Equal to compare actual with expected. Equal is strict about types when performing comparisons. It is an error for both actual and expected to be nil. Use BeNil() instead.

func GenerateRandomString added in v0.18.0

func GenerateRandomString(length int) string

func GetRelationship added in v0.23.0

func GetRelationship(
	sourceExternalID string,
	sourceType string,
	targetExternalID string,
	targetType string,
	relationType string) *ingestpb.Relationship

func InitConfigAuthorization added in v0.18.0

func InitConfigAuthorization() (*authorization.Client, error)

InitConfigAuthorization reads in config file and ENV variables if set.

func InitConfigConfig added in v0.25.0

func InitConfigConfig() (*config.Client, error)

InitConfigConfig file and ENV variables if set.

func InitConfigEntitymatching added in v0.40.0

func InitConfigEntitymatching() (*entitymatching.Client, error)

InitConfigEntitymatching reads in entitymatching file and ENV variables if set.

func InitConfigIngest added in v0.18.0

func InitConfigIngest() (*ingest.Client, error)

InitConfigIngest reads in ingest file and ENV variables if set.

func InitConfigIngestRetry added in v0.18.0

func InitConfigIngestRetry() (*ingest.RetryClient, error)

InitConfigIngestRetry reads in ingest file and ENV variables if set.

func InitConfigTda added in v0.30.1

func InitConfigTda() (*tda.Client, error)

InitConfigTda reads in tda file and ENV variables if set.

func MatchErrorCode

func MatchErrorCode(errorCode codes.Code) types.GomegaMatcher

MatchErrorCode succeeds if actual is a non-nil error that has the code the passed in error.

Error must be google.golang.org/grpc/status.Error It is an error for err to be nil or an object that does not implement the Error interface.

func MatchJSON

func MatchJSON(expected any) types.GomegaMatcher

MatchJSON uses the expected value to build a value matcher.

func MatchProtoMessage

func MatchProtoMessage(message proto.Message) types.GomegaMatcher

MatchProtoMessage succeeds if.

func MatchStatusError

func MatchStatusError(errorCode codes.Code, msg any) types.GomegaMatcher

MatchStatusError succeeds if actual is a non-nil error that has the code the passed in error.

Error must be google.golang.org/grpc/status.Error It is an error for err to be nil or an object that does not implement the Error interface.

func UpsertRecordNodeAsset added in v0.23.0

func UpsertRecordNodeAsset() (*ingestpb.Record, string)

func WrapMatcher added in v0.14.0

func WrapMatcher(matcher types.GomegaMatcher) gomock.Matcher

Types

type EqualAnyProtoMatcher

type EqualAnyProtoMatcher struct {
	Expected proto.Message
	// contains filtered or unexported fields
}

func (*EqualAnyProtoMatcher) FailureMessage

func (matcher *EqualAnyProtoMatcher) FailureMessage(any) string

func (*EqualAnyProtoMatcher) Match

func (matcher *EqualAnyProtoMatcher) Match(actual any) (bool, error)

func (*EqualAnyProtoMatcher) NegatedFailureMessage

func (matcher *EqualAnyProtoMatcher) NegatedFailureMessage(any) string

type EqualProtoMatcher

type EqualProtoMatcher struct {
	Expected proto.Message
}

func (*EqualProtoMatcher) FailureMessage

func (matcher *EqualProtoMatcher) FailureMessage(actual any) string

func (*EqualProtoMatcher) GomegaString

func (matcher *EqualProtoMatcher) GomegaString() string

func (*EqualProtoMatcher) Match

func (matcher *EqualProtoMatcher) Match(actual any) (bool, error)

func (*EqualProtoMatcher) NegatedFailureMessage

func (matcher *EqualProtoMatcher) NegatedFailureMessage(actual any) string

type MatchJSONMatcher

type MatchJSONMatcher struct {
	types.GomegaMatcher
}

func (*MatchJSONMatcher) Match

func (matcher *MatchJSONMatcher) Match(actual any) (bool, error)

type MatchProtoMessageMatcher

type MatchProtoMessageMatcher struct {
	Expected proto.Message
}

func (*MatchProtoMessageMatcher) FailureMessage

func (matcher *MatchProtoMessageMatcher) FailureMessage(actual any) string

func (*MatchProtoMessageMatcher) Match

func (matcher *MatchProtoMessageMatcher) Match(actual any) (bool, error)

func (*MatchProtoMessageMatcher) NegatedFailureMessage

func (matcher *MatchProtoMessageMatcher) NegatedFailureMessage(actual any) string

type MatchSDKStatusErrorMatcher

type MatchSDKStatusErrorMatcher struct {
	Expected codes.Code
	// contains filtered or unexported fields
}

func (*MatchSDKStatusErrorMatcher) FailureMessage

func (matcher *MatchSDKStatusErrorMatcher) FailureMessage(actual any) string

func (*MatchSDKStatusErrorMatcher) Match

func (matcher *MatchSDKStatusErrorMatcher) Match(actual any) (bool, error)

func (*MatchSDKStatusErrorMatcher) NegatedFailureMessage

func (matcher *MatchSDKStatusErrorMatcher) NegatedFailureMessage(actual any) string

Directories

Path Synopsis
authorization
v1beta1
Package authorization is a generated GoMock package.
Package authorization is a generated GoMock package.
config
v1beta1
Package config is a generated GoMock package.
Package config is a generated GoMock package.
entitymatching
v1beta1
Package entitymatching is a generated GoMock package.
Package entitymatching is a generated GoMock package.
ingest
v1beta3
Package ingest is a generated GoMock package.
Package ingest is a generated GoMock package.
knowledge
v1beta1
Package knowledge is a generated GoMock package.
Package knowledge is a generated GoMock package.
v1beta2
Package knowledge is a generated GoMock package.
Package knowledge is a generated GoMock package.
tda
v1beta1
Package tda is a generated GoMock package.
Package tda is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL