Skip to content

Commit

Permalink
chore: capture upgrading to rest_numeric_enums=False in baseline (#120)
Browse files Browse the repository at this point in the history
This also cleans up code by resolving a TODO
  • Loading branch information
vchudnov-g committed Nov 3, 2022
1 parent 1bb17c8 commit 3441efb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
Expand Up @@ -189,7 +189,7 @@ py_gapic_library(
name = "library_py_gapic",
srcs = [":library_proto"],
grpc_service_config = "library_example_grpc_service_config.json",
rest_numeric_enums = True,
rest_numeric_enums = False,
service_yaml = "library_example_v1.yaml",
transport = "grpc+rest",
deps = [
Expand Down
Expand Up @@ -134,7 +134,9 @@ public void testRegeneration() throws IOException, InterruptedException {
buildozer.batchSetStringAttribute(
gapicBuildFilePath, "library_java_gapic", "transport", "lightning");
buildozer.batchRemoveAttribute(
gapicBuildFilePath, "library_go_gapic", "rest_numeric_enums");
gapicBuildFilePath, "library_py_gapic", "rest_numeric_enums");
buildozer.batchSetStringAttribute(
gapicBuildFilePath, "library_go_gapic", "rest_numeric_enums", "Apennines");

// The following values should NOT be preserved:
buildozer.batchSetStringAttribute(
Expand Down Expand Up @@ -176,6 +178,9 @@ public void testRegeneration() throws IOException, InterruptedException {
buildozer.getAttribute(gapicBuildFilePath, "%java_gapic_library", "transport"));
Assert.assertEquals(
"False",
buildozer.getAttribute(gapicBuildFilePath, "%py_gapic_library", "rest_numeric_enums"));
Assert.assertEquals(
"Apennines",
buildozer.getAttribute(gapicBuildFilePath, "%go_gapic_library", "rest_numeric_enums"));

// Check that grpc_service_config value is not preserved:
Expand All @@ -186,22 +191,6 @@ public void testRegeneration() throws IOException, InterruptedException {
// Check that the changed root file is preserved
Assert.assertEquals(changedRootContent, ApisVisitor.readFile(rootBuildFilePath));


//// START section to be consolidated
// TODO: Consolidate this test attribute change with the other ones above, so we only run
// `buildozer.commit() and the BuildFileGenerator once. To do this, we need to make each change
// in a separate language, but at the moment, we're only supporting "rest_numeric_enums" in one
// language.
buildozer.batchSetStringAttribute(
gapicBuildFilePath, "library_go_gapic", "rest_numeric_enums", "Apennines");
buildozer.commit();
new BuildFileGenerator()
.generateBuildFiles(args.createApisVisitor(null, tempDirPath.toString()));
Assert.assertEquals(
"Apennines",
buildozer.getAttribute(gapicBuildFilePath, "%go_gapic_library", "rest_numeric_enums"));
//// END section to be consolidated

// Since buildozer does not differentiate between string and non-string values, we need to
// compare to a baseline to ensure the updates were coded with or without quotes, as appropriate.
ArgsParser argsUpdate =
Expand Down

0 comments on commit 3441efb

Please sign in to comment.