Skip to content

Commit 0cc562d

Browse files
authored
feat: add local bzlmod consumer test (googleapis#15339)
This commit adds a minimal Bazel project that consumes google-cloud-cpp as an external dependency using Bzlmod. The test is designed to reproduce the canonical repository name mismatch reported in b/430085995 and will be used to verify that the changes in this pull request resolve the issue from a downstream user's perspective.
1 parent 911d67d commit 0cc562d

3 files changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
load("@rules_cc//cc:defs.bzl", "cc_test")
2+
3+
cc_test(
4+
name = "main_test",
5+
srcs = ["main.cc"],
6+
deps = [
7+
"@google_cloud_cpp//google/cloud/storage:storage_client_testing",
8+
],
9+
)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module(name = "bzlmod-consumer-test")
2+
3+
bazel_dep(name = "google_cloud_cpp", version = "3.0.0-rc0")
4+
bazel_dep(name = "googletest", version = "1.15.2")
5+
bazel_dep(name = "rules_cc", version = "0.1.1")
6+
7+
local_path_override(
8+
module_name = "google_cloud_cpp",
9+
path = "/workspace/google-cloud-cpp",
10+
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include "google/cloud/storage/client.h"
2+
#include "google/cloud/storage/testing/mock_client.h"
3+
#include <gmock/gmock.h>
4+
#include <gtest/gtest.h>
5+
6+
TEST(BzlmodTest, CanCreateMockClient) {
7+
// Create a mock client.
8+
auto mock = std::make_shared<google::cloud::storage::testing::MockClient>();
9+
10+
// Use the mock to construct a Client object. This verifies that the
11+
// necessary symbols are linked correctly.
12+
google::cloud::storage::Client client(mock);
13+
14+
// A simple assertion to make it a valid test.
15+
ASSERT_TRUE(true);
16+
}

0 commit comments

Comments
 (0)