Atlas › Test

TestWithValidMessage

Exact test identity: go.temporal.io/server/common/protocol/TestWithValidMessage

Package
go.temporal.io/server/common/protocol
Suite / test hierarchy
TestWithValidMessage
Test
TestWithValidMessage
Introduced at
TestWithValidMessage Frontier kind: Test frontier
Covered ranges
8
Covered lines
19
Covered files
1

Covered source

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

go.temporal.io/server/common/protocol/naming.go 19 covered LOC · 8 ranges

Open complete file

30
31 // String transforms a MessageType into a string
32 > func (mt MessageType) String() string { naming.go
33 > return string(mt)
34 > }
35
36 // String tranforms a Type into a string
37 > func (pt Type) String() string { naming.go
38 > return string(pt)
39 > }
40
41 // Identify is a function that given a protocol message gives the specific
42 // message type of the body and the type of the protocol to which this message
43 // belongs.
44 > func Identify(msg *protocolpb.Message) (Type, MessageType, error) { naming.go
45 > if msg == nil {
46 return TypeUnknown, MessageTypeUnknown, errNilMsg
47 > } else if msg.Body == nil { naming.go
48 return TypeUnknown, MessageTypeUnknown, errNilBody
49 }
50
51 > bodyTypeName := string(msg.Body.MessageName()) naming.go
52 > if bodyTypeName == "" {
53 return TypeUnknown, MessageTypeUnknown, errNoName
54 }
55
56 > msgType := MessageType(bodyTypeName) naming.go
57 > lastDot := strings.LastIndex(bodyTypeName, ".")
58 > if lastDot < 0 {
59 err := fmt.Errorf("%w: no . found in %q", errProtoFmt, bodyTypeName)
60 return TypeUnknown, msgType, err
61 }
62 > return Type(bodyTypeName[0:lastDot]), msgType, nil naming.go
63 }
64
66 // MessageTypeUnknown in the case where either one cannot be determined due to
67 // an error.
68 > func IdentifyOrUnknown(msg *protocolpb.Message) (Type, MessageType) { naming.go
69 > pt, mt, _ := Identify(msg)
70 > return pt, mt
71 > }
72
73 func (cerr constErr) Error() string {