compile_build_api_proto: Add test to verify versions.
compile_build_api_proto must use a version of protoc that is compatible
with the vendored protobuf library. Add a test to verify the versions
match.
BUG=chromium:1181505
TEST=./run_pytest
Change-Id: Ia8d5cc29a1635da4842801bb682b42804ecea389
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2717370
Commit-Queue: Alex Klein <saklein@chromium.org>
Tested-by: Alex Klein <saklein@chromium.org>
Auto-Submit: Alex Klein <saklein@chromium.org>
Reviewed-by: Michael Mortensen <mmortensen@google.com>
Reviewed-by: LaMont Jones <lamontjones@chromium.org>
diff --git a/api/compile_build_api_proto_unittest.py b/api/compile_build_api_proto_unittest.py
new file mode 100644
index 0000000..135ca0a
--- /dev/null
+++ b/api/compile_build_api_proto_unittest.py
@@ -0,0 +1,25 @@
+# Copyright 2021 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""compile_build_api_proto tests."""
+
+from google import protobuf
+from chromite.api import compile_build_api_proto
+
+
+def test_versions_match():
+ """Verify the versions match.
+
+ The protoc version in the compile script needs to be compatible with the
+ version of the library we're using (in chromite/third_party). For now, that
+ means we're checking equality.
+
+ TODO: Investigate whether, e.g. 1.2.0 ~= 1.2.3, and we only need to check the
+ major and minor components.
+ TODO: Investigate using protobuf.__version__ instead of hard coding a version
+ in compile_build_api_proto.
+ """
+ assert compile_build_api_proto.PROTOC_VERSION == protobuf.__version__, (
+ 'The protobuf library or compile_build_api_proto.PROTOC_VERSION has been '
+ 'updated, but the other has not. They must be updated together.')