Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate ClientCallUnary test stubs. #398

Merged
merged 2 commits into from
Mar 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/Examples/Echo/Generated/echo.grpc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ fileprivate final class Echo_EchoGetCallBase: ClientCallUnaryBase<Echo_EchoReque
override class var method: String { return "/echo.Echo/Get" }
}

class Echo_EchoGetCallTestStub: ClientCallUnaryTestStub, Echo_EchoGetCall {
override class var method: String { return "/echo.Echo/Get" }
}

internal protocol Echo_EchoExpandCall: ClientCallServerStreaming {
/// Do not call this directly, call `receive()` in the protocol extension below instead.
func _receive(timeout: DispatchTime) throws -> Echo_EchoResponse?
Expand Down
7 changes: 7 additions & 0 deletions Sources/SwiftGRPC/Runtime/ClientCallUnary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,10 @@ open class ClientCallUnaryBase<InputType: Message, OutputType: Message>: ClientC
return self
}
}

/// Simple fake implementation of `ClientCallUnary`.
open class ClientCallUnaryTestStub: ClientCallUnary {
open class var method: String { fatalError("needs to be overridden") }

open func cancel() {}
}
8 changes: 8 additions & 0 deletions Sources/protoc-gen-swiftgrpc/Generator-Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ extension Generator {
println("override class var method: String { return \(methodPath) }")
outdent()
println("}")
if options.generateTestStubs {
println()
println("class \(callName)TestStub: ClientCallUnaryTestStub, \(callName) {")
indent()
println("override class var method: String { return \(methodPath) }")
outdent()
println("}")
}
println()
}

Expand Down