Atlas › Test

HappyPath

Exact test identity: go.temporal.io/server/common/links/TestValidate/HappyPath

Package
go.temporal.io/server/common/links
Suite / test hierarchy
TestValidate/HappyPath
Test
HappyPath
Introduced at
HappyPath Frontier kind: Test frontier
Covered ranges
16
Covered lines
21
Covered files
1

Covered source

Expand a file to inspect source; the > gutter marks covered lines.

go.temporal.io/server/common/links/validator.go 21 covered LOC · 16 ranges

Open complete file

12 // populated.
13 // nolint:revive // cognitive-complexity is high but justified to keep each case together for readability.
14 > func Validate(links []*commonpb.Link, maxAllowedLinks, maxSize int) error { validator.go
15 > if len(links) > maxAllowedLinks {
16 return serviceerror.NewInvalidArgumentf("cannot attach more than %d links per request, got %d", maxAllowedLinks, len(links))
17 }
18 > for _, l := range links { validator.go
19 > if l.Size() > maxSize { validator.go
20 return serviceerror.NewInvalidArgumentf("link exceeds allowed size of %d, got %d", maxSize, l.Size())
21 }
22 > switch t := l.Variant.(type) { validator.go
23 > case *commonpb.Link_WorkflowEvent_: validator.go
24 > if t.WorkflowEvent.GetNamespace() == "" {
25 return serviceerror.NewInvalidArgument("workflow event link must not have an empty namespace field")
26 }
27 > if t.WorkflowEvent.GetWorkflowId() == "" { validator.go
28 return serviceerror.NewInvalidArgument("workflow event link must not have an empty workflow ID field")
29 }
30 > if t.WorkflowEvent.GetRunId() == "" { validator.go
31 return serviceerror.NewInvalidArgument("workflow event link must not have an empty run ID field")
32 }
33 > if t.WorkflowEvent.GetEventRef().GetEventType() == enumspb.EVENT_TYPE_UNSPECIFIED && t.WorkflowEvent.GetEventRef().GetEventId() != 0 { validator.go
34 return serviceerror.NewInvalidArgument("workflow event link ref cannot have an unspecified event type and a non-zero event ID")
35 }
36 > case *commonpb.Link_BatchJob_: validator.go
37 > if t.BatchJob.GetJobId() == "" {
38 return serviceerror.NewInvalidArgument("batch job link must not have an empty job ID")
39 }
40 > case *commonpb.Link_NexusOperation_: validator.go
41 > if t.NexusOperation.GetNamespace() == "" {
42 return serviceerror.NewInvalidArgument("nexus operation link must not have an empty namespace field")
43 }
44 > if t.NexusOperation.GetOperationId() == "" { validator.go
45 return serviceerror.NewInvalidArgument("nexus operation link must not have an empty operation ID field")
46 }
47 > if t.NexusOperation.GetRunId() == "" { validator.go
48 return serviceerror.NewInvalidArgument("nexus operation link must not have an empty run ID field")
49 }
50 > case *commonpb.Link_Activity_: validator.go
51 > if t.Activity.GetNamespace() == "" {
52 return serviceerror.NewInvalidArgument("activity link must not have an empty namespace field")
53 }
54 > if t.Activity.GetActivityId() == "" { validator.go
55 return serviceerror.NewInvalidArgument("activity link must not have an empty activity ID field")
56 }
57 > if t.Activity.GetRunId() == "" { validator.go
58 return serviceerror.NewInvalidArgument("activity link must not have an empty run ID field")
59 }