|
@@ -471,22 +471,52 @@ final class ProtobufCodeGeneratorTests: XCTestCase {
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ func testNoAccessLevelOnImports() throws {
|
|
|
|
|
+ let proto = Google_Protobuf_FileDescriptorProto(name: "helloworld.proto", package: "")
|
|
|
|
|
+ try testCodeGeneration(
|
|
|
|
|
+ proto: proto,
|
|
|
|
|
+ indentation: 2,
|
|
|
|
|
+ visibility: .package,
|
|
|
|
|
+ client: true,
|
|
|
|
|
+ server: true,
|
|
|
|
|
+ accessLevelOnImports: false,
|
|
|
|
|
+ expectedCode: """
|
|
|
|
|
+ // DO NOT EDIT.
|
|
|
|
|
+ // swift-format-ignore-file
|
|
|
|
|
+ //
|
|
|
|
|
+ // Generated by the gRPC Swift generator plugin for the protocol buffer compiler.
|
|
|
|
|
+ // Source: helloworld.proto
|
|
|
|
|
+ //
|
|
|
|
|
+ // For information on using the generated types, please see the documentation:
|
|
|
|
|
+ // https://github.com/grpc/grpc-swift
|
|
|
|
|
+
|
|
|
|
|
+ import GRPCCore
|
|
|
|
|
+ import GRPCProtobuf
|
|
|
|
|
+ import ExtraModule
|
|
|
|
|
+
|
|
|
|
|
+ """
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
func testCodeGeneration(
|
|
func testCodeGeneration(
|
|
|
proto: Google_Protobuf_FileDescriptorProto,
|
|
proto: Google_Protobuf_FileDescriptorProto,
|
|
|
indentation: Int,
|
|
indentation: Int,
|
|
|
visibility: SourceGenerator.Configuration.AccessLevel,
|
|
visibility: SourceGenerator.Configuration.AccessLevel,
|
|
|
client: Bool,
|
|
client: Bool,
|
|
|
server: Bool,
|
|
server: Bool,
|
|
|
|
|
+ accessLevelOnImports: Bool = true,
|
|
|
expectedCode: String,
|
|
expectedCode: String,
|
|
|
file: StaticString = #filePath,
|
|
file: StaticString = #filePath,
|
|
|
line: UInt = #line
|
|
line: UInt = #line
|
|
|
) throws {
|
|
) throws {
|
|
|
- let configs = SourceGenerator.Configuration(
|
|
|
|
|
|
|
+ let config = SourceGenerator.Configuration(
|
|
|
accessLevel: visibility,
|
|
accessLevel: visibility,
|
|
|
|
|
+ accessLevelOnImports: accessLevelOnImports,
|
|
|
client: client,
|
|
client: client,
|
|
|
server: server,
|
|
server: server,
|
|
|
indentation: indentation
|
|
indentation: indentation
|
|
|
)
|
|
)
|
|
|
|
|
+
|
|
|
let descriptorSet = DescriptorSet(
|
|
let descriptorSet = DescriptorSet(
|
|
|
protos: [
|
|
protos: [
|
|
|
Google_Protobuf_FileDescriptorProto(name: "same-module.proto", package: "same-package"),
|
|
Google_Protobuf_FileDescriptorProto(name: "same-module.proto", package: "same-package"),
|
|
@@ -512,7 +542,7 @@ final class ProtobufCodeGeneratorTests: XCTestCase {
|
|
|
}
|
|
}
|
|
|
]
|
|
]
|
|
|
}
|
|
}
|
|
|
- let generator = ProtobufCodeGenerator(configuration: configs)
|
|
|
|
|
|
|
+ let generator = ProtobufCodeGenerator(configuration: config)
|
|
|
try XCTAssertEqualWithDiff(
|
|
try XCTAssertEqualWithDiff(
|
|
|
try generator.generateCode(
|
|
try generator.generateCode(
|
|
|
from: fileDescriptor,
|
|
from: fileDescriptor,
|