Atlas › Test

Nested_proto_struct

Exact test identity: go.temporal.io/server/common/testing/protorequire/TestProtoElementsMatch/Nested_proto_struct

Package
go.temporal.io/server/common/testing/protorequire
Suite / test hierarchy
TestProtoElementsMatch/Nested_proto_struct
Test
Nested_proto_struct
Introduced at
require.go ×1 Frontier kind: Joint frontier
Covered ranges
6
Covered lines
16
Covered files
1

Co-introduced tests

1 other test enter at the same concept.

Covered source

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

go.temporal.io/server/common/testing/protorequire/require.go 16 covered LOC · 6 ranges

Open complete file

89 // ProtoElementsMatch behaves like require.ElementsMatch except in that it works for protobuf-generated structs.
90 // Both arguments must be slices or arrays.
91 > func ProtoElementsMatch(t require.TestingT, a any, b any, msgAndArgs ...any) { require.go
92 > if th, ok := t.(helper); ok {
93 th.Helper()
94 }
95 > aVal := reflect.ValueOf(a) require.go
96 > bVal := reflect.ValueOf(b)
97 > if aVal.Len() != bVal.Len() {
98 require.Fail(t, fmt.Sprintf("element count mismatch: want %d, got %d\nA: %+v\nB: %+v", aVal.Len(), bVal.Len(), a, b), msgAndArgs...)
99 return
100 }
101 > used := make([]bool, bVal.Len()) require.go
102 > for i := 0; i < aVal.Len(); i++ {
103 > want := aVal.Index(i).Interface()
104 > matched := false
105 > for j := 0; j < bVal.Len(); j++ {
106 > if used[j] {
107 continue
108 }
109 > if temporalproto.DeepEqual(want, bVal.Index(j).Interface()) { require.go
110 > used[j] = true require.go
111 > matched = true
112 > break
113 }
114 }
115 > if !matched { require.go
116 require.Fail(t, fmt.Sprintf("element not found in B: %+v\nA: %+v\nB: %+v", want, a, b), msgAndArgs...)
117 return