Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
5937cdd7
Commit
5937cdd7
authored
7 years ago
by
makdharma
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #11047 from makdharma/objc_trailer_test
Added a binary trailer test
parents
af3cc761
716c7c52
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/objective-c/tests/GRPCClientTests.m
+29
-0
29 additions, 0 deletions
src/objective-c/tests/GRPCClientTests.m
with
29 additions
and
0 deletions
src/objective-c/tests/GRPCClientTests.m
+
29
−
0
View file @
5937cdd7
...
...
@@ -293,6 +293,35 @@ static GRPCProtoMethod *kUnaryCallMethod;
[
self
waitForExpectationsWithTimeout
:
TEST_TIMEOUT
handler
:
nil
];
}
-
(
void
)
testTrailers
{
__weak
XCTestExpectation
*
response
=
[
self
expectationWithDescription
:
@"Empty response received."
];
__weak
XCTestExpectation
*
completion
=
[
self
expectationWithDescription
:
@"Empty RPC completed."
];
GRPCCall
*
call
=
[[
GRPCCall
alloc
]
initWithHost
:
kHostAddress
path:
kEmptyCallMethod
.
HTTPPath
requestsWriter:
[
GRXWriter
writerWithValue
:[
NSData
data
]]];
// Setting this special key in the header will cause the interop server to echo back the
// trailer data.
const
unsigned
char
raw_bytes
[]
=
{
1
,
2
,
3
,
4
};
NSData
*
trailer_data
=
[
NSData
dataWithBytes
:
raw_bytes
length
:
sizeof
(
raw_bytes
)];
call
.
requestHeaders
[
@"x-grpc-test-echo-trailing-bin"
]
=
trailer_data
;
id
<
GRXWriteable
>
responsesWriteable
=
[[
GRXWriteable
alloc
]
initWithValueHandler
:
^
(
NSData
*
value
)
{
XCTAssertNotNil
(
value
,
@"nil value received as response."
);
XCTAssertEqual
([
value
length
],
0
,
@"Non-empty response received: %@"
,
value
);
[
response
fulfill
];
}
completionHandler
:
^
(
NSError
*
errorOrNil
)
{
XCTAssertNil
(
errorOrNil
,
@"Finished with unexpected error: %@"
,
errorOrNil
);
XCTAssertEqualObjects
((
NSData
*
)
call
.
responseTrailers
[
@"x-grpc-test-echo-trailing-bin"
],
trailer_data
,
@"Did not receive expected trailer"
);
[
completion
fulfill
];
}];
[
call
startWithWriteable
:
responsesWriteable
];
[
self
waitForExpectationsWithTimeout
:
TEST_TIMEOUT
handler
:
nil
];
}
// TODO(makarandd): Move to a different file that contains only unit tests
-
(
void
)
testExceptions
{
// Try to set parameters to nil for GRPCCall. This should cause an exception
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment