Skip to content

Commit b2302af

Browse files
committed
update tests for combined payloads
1 parent 100cc17 commit b2302af

File tree

4 files changed

+24
-33
lines changed

4 files changed

+24
-33
lines changed

lib/grpc_reflection/service/state.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ defmodule GrpcReflection.Service.State do
141141
%{
142142
acc
143143
| syntax: descriptor.syntax,
144-
message_type: acc.message_type ++ descriptor.message_type,
145-
service: acc.service ++ descriptor.service,
146-
enum_type: acc.enum_type ++ descriptor.enum_type,
147-
dependency: acc.dependency ++ descriptor.dependency,
148-
extension: acc.extension ++ descriptor.extension
144+
message_type: Enum.uniq(acc.message_type ++ descriptor.message_type),
145+
service: Enum.uniq(acc.service ++ descriptor.service),
146+
enum_type: Enum.uniq(acc.enum_type ++ descriptor.enum_type),
147+
dependency: Enum.uniq(acc.dependency ++ descriptor.dependency),
148+
extension: Enum.uniq(acc.extension ++ descriptor.extension)
149149
}
150150
end
151151
)

test/integration/v1_reflection_test.exs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ defmodule GrpcReflection.V1ReflectionTest do
7474
test "describing a nested type returns the root type", ctx do
7575
message = {:file_containing_symbol, "testserviceV3.TestRequest.Payload"}
7676
assert {:ok, response} = run_request(message, ctx)
77-
assert response.name == "testserviceV3.TestRequest.proto"
77+
assert response.name == "testserviceV3.proto"
7878
end
7979

8080
test "type with leading period still resolves", ctx do
@@ -167,29 +167,30 @@ defmodule GrpcReflection.V1ReflectionTest do
167167
end
168168

169169
test "ensures file descriptor dependencies are unique", ctx do
170-
filename = "testserviceV3.TestReply.proto"
170+
filename = "testserviceV3.proto"
171171
message = {:file_by_filename, filename}
172172
assert {:ok, response} = run_request(message, ctx)
173173
assert response.name == filename
174174
assert response.package == "testserviceV3"
175175

176176
assert response.dependency == [
177177
"google.protobuf.Timestamp.proto",
178-
"google.protobuf.StringValue.proto"
178+
"google.protobuf.StringValue.proto",
179+
"google.protobuf.Any.proto"
179180
]
180181
end
181182

182183
test "ensure exclusion of nested types in file descriptor dependencies", ctx do
183-
filename = "testserviceV3.TestRequest.proto"
184+
filename = "testserviceV3.proto"
184185
message = {:file_by_filename, filename}
185186
assert {:ok, response} = run_request(message, ctx)
186187
assert response.name == filename
187188
assert response.package == "testserviceV3"
188189

189190
assert response.dependency == [
190-
"testserviceV3.Enum.proto",
191-
"google.protobuf.Any.proto",
192-
"google.protobuf.StringValue.proto"
191+
"google.protobuf.Timestamp.proto",
192+
"google.protobuf.StringValue.proto",
193+
"google.protobuf.Any.proto"
193194
]
194195
end
195196
end

test/integration/v1alpha_reflection_test.exs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ defmodule GrpcReflection.V1alphaReflectionTest do
7474
test "describing a nested type returns the root type", ctx do
7575
message = {:file_containing_symbol, "testserviceV3.TestRequest.Payload"}
7676
assert {:ok, response} = run_request(message, ctx)
77-
assert response.name == "testserviceV3.TestRequest.proto"
77+
assert response.name == "testserviceV3.proto"
7878
end
7979

8080
test "type with leading period still resolves", ctx do
@@ -167,29 +167,30 @@ defmodule GrpcReflection.V1alphaReflectionTest do
167167
end
168168

169169
test "ensures file descriptor dependencies are unique", ctx do
170-
filename = "testserviceV3.TestReply.proto"
170+
filename = "testserviceV3.proto"
171171
message = {:file_by_filename, filename}
172172
assert {:ok, response} = run_request(message, ctx)
173173
assert response.name == filename
174174
assert response.package == "testserviceV3"
175175

176176
assert response.dependency == [
177177
"google.protobuf.Timestamp.proto",
178-
"google.protobuf.StringValue.proto"
178+
"google.protobuf.StringValue.proto",
179+
"google.protobuf.Any.proto"
179180
]
180181
end
181182

182183
test "ensure exclusion of nested types in file descriptor dependencies", ctx do
183-
filename = "testserviceV3.TestRequest.proto"
184+
filename = "testserviceV3.proto"
184185
message = {:file_by_filename, filename}
185186
assert {:ok, response} = run_request(message, ctx)
186187
assert response.name == filename
187188
assert response.package == "testserviceV3"
188189

189190
assert response.dependency == [
190-
"testserviceV3.Enum.proto",
191-
"google.protobuf.Any.proto",
192-
"google.protobuf.StringValue.proto"
191+
"google.protobuf.Timestamp.proto",
192+
"google.protobuf.StringValue.proto",
193+
"google.protobuf.Any.proto"
193194
]
194195
end
195196
end

test/service/builder_test.exs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@ defmodule GrpcReflection.Service.BuilderTest do
1414
"google.protobuf.Any.proto",
1515
"google.protobuf.StringValue.proto",
1616
"google.protobuf.Timestamp.proto",
17-
"testserviceV3.Enum.proto",
18-
"testserviceV3.TestReply.proto",
19-
"testserviceV3.TestRequest.Payload.proto",
20-
"testserviceV3.TestRequest.Token.proto",
21-
"testserviceV3.TestRequest.proto",
22-
"testserviceV3.TestService.proto"
17+
"testserviceV3.proto"
2318
]
2419

2520
assert Map.keys(tree.symbols) == [
@@ -49,11 +44,8 @@ defmodule GrpcReflection.Service.BuilderTest do
4944
assert Map.keys(tree.files) == [
5045
"google.protobuf.Any.proto",
5146
"google.protobuf.Timestamp.proto",
52-
"testserviceV2.Enum.proto",
53-
"testserviceV2.TestReply.proto",
54-
"testserviceV2.TestRequest.proto",
5547
"testserviceV2.TestRequestExtension.proto",
56-
"testserviceV2.TestService.proto"
48+
"testserviceV2.proto"
5749
]
5850

5951
assert Map.keys(tree.symbols) == [
@@ -111,11 +103,8 @@ defmodule GrpcReflection.Service.BuilderTest do
111103
assert names == [
112104
"google.protobuf.Any.proto",
113105
"google.protobuf.Timestamp.proto",
114-
"testserviceV2.Enum.proto",
115-
"testserviceV2.TestReply.proto",
116-
"testserviceV2.TestRequest.proto",
117106
"testserviceV2.TestRequestExtension.proto",
118-
"testserviceV2.TestService.proto"
107+
"testserviceV2.proto"
119108
]
120109
end
121110

0 commit comments

Comments
 (0)