def do_build_flow(self, **kwargs): flow = linear_flow.Flow('core-protogen') flow.add( protoc_tasks.ProtoCodeGenTask('CoreProtoGen', inject=kwargs), gapic_tasks.GoExtractImportBaseTask('ExtractGoPackageName', inject=kwargs), protoc_tasks.GoLangUpdateImportsTask('UpdateImports', inject=kwargs)) return flow
def do_build_flow(self, **kwargs): flow = linear_flow.Flow('grpc-protogen') flow.add( protoc_tasks.ProtoAndGrpcCodeGenTask('GrpcCodegen', inject=kwargs), veneer_tasks.GoExtractImportBaseTask('ExtractGoPackageName', inject=kwargs), protoc_tasks.GoLangUpdateImportsTask('UpdateImports', inject=kwargs)) return flow
def test_golang_update_imports_task(tmpdir): task = protoc_tasks.GoLangUpdateImportsTask('test') output_dir = tmpdir.mkdir('out') final_repo_dir = tmpdir.mkdir('final') pkg_dir = output_dir.mkdir('fake-gen-go') shutil.copy('test/fake-repos/fake-proto/fake.pb.go', str(pkg_dir)) task.execute(api_name='fake', language='go', go_import_base='example.com/fake', output_dir=str(output_dir), final_repo_dir=str(final_repo_dir)) with open(os.path.join(str(final_repo_dir), 'proto', 'fake.pb.go')) as f: actual = f.read() with open('test/testdata/go_grpc_expected_fake.pb.go') as f: expected = f.read() assert actual == expected