-
Notifications
You must be signed in to change notification settings - Fork 455
Expand file tree
/
Copy pathinstance_config_test.cc
More file actions
102 lines (85 loc) · 3.69 KB
/
Copy pathinstance_config_test.cc
File metadata and controls
102 lines (85 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "google/cloud/bigtable/instance_config.h"
#include <gmock/gmock.h>
namespace google {
namespace cloud {
namespace bigtable {
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
namespace {
TEST(InstanceConfigTest, Constructor) {
InstanceConfig config("my-instance", "pretty name",
{{"my-cluster", {"somewhere", 7, ClusterConfig::SSD}}});
auto const& proto = config.as_proto();
EXPECT_EQ("my-instance", proto.instance_id());
EXPECT_EQ("pretty name", proto.instance().display_name());
ASSERT_EQ(1, proto.clusters_size());
auto cluster = proto.clusters().at("my-cluster");
EXPECT_EQ("somewhere", cluster.location());
EXPECT_EQ(7, cluster.serve_nodes());
EXPECT_EQ(ClusterConfig::SSD, cluster.default_storage_type());
}
TEST(InstanceConfigTest, ConstructorManyClusters) {
InstanceConfig config("my-instance", "pretty name",
{
{"cluster-1", {"somewhere", 7, ClusterConfig::SSD}},
{"cluster-2", {"elsewhere", 7, ClusterConfig::HDD}},
{"cluster-3", {"nowhere", 17, ClusterConfig::HDD}},
});
auto const& proto = config.as_proto();
EXPECT_EQ("my-instance", proto.instance_id());
EXPECT_EQ("pretty name", proto.instance().display_name());
ASSERT_EQ(3, proto.clusters_size());
auto c1 = proto.clusters().at("cluster-1");
EXPECT_EQ("somewhere", c1.location());
EXPECT_EQ(7, c1.serve_nodes());
EXPECT_EQ(ClusterConfig::SSD, c1.default_storage_type());
auto c3 = proto.clusters().at("cluster-3");
EXPECT_EQ("nowhere", c3.location());
EXPECT_EQ(17, c3.serve_nodes());
EXPECT_EQ(ClusterConfig::HDD, c3.default_storage_type());
}
TEST(InstanceConfigTest, SetLabels) {
InstanceConfig config("my-instance", "pretty name",
{
{"cluster-1", {"somewhere", 7, ClusterConfig::SSD}},
});
config.insert_label("foo", "bar").emplace_label("baz", "qux");
auto proto = config.as_proto();
EXPECT_EQ("my-instance", proto.instance_id());
EXPECT_EQ("pretty name", proto.instance().display_name());
ASSERT_EQ(1, proto.clusters_size());
ASSERT_EQ(2, proto.instance().labels_size());
EXPECT_EQ("bar", proto.instance().labels().at("foo"));
EXPECT_EQ("qux", proto.instance().labels().at("baz"));
}
TEST(InstanceConfigTest, SetTags) {
InstanceConfig config("my-instance", "pretty name",
{
{"cluster-1", {"somewhere", 7, ClusterConfig::SSD}},
});
config.insert_tag("tagKeys/123", "tagValues/654").emplace_tag("tagKeys/345", "tagValues/987");
auto proto = config.as_proto();
EXPECT_EQ("my-instance", proto.instance_id());
EXPECT_EQ("pretty name", proto.instance().display_name());
ASSERT_EQ(1, proto.clusters_size());
ASSERT_EQ(2, proto.instance().tags_size());
EXPECT_EQ("tagValues/654", proto.instance().tags().at("tagKeys/123"));
EXPECT_EQ("tagValues/987", proto.instance().tags().at("tagKeys/345"));
}
} // namespace
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
} // namespace bigtable
} // namespace cloud
} // namespace google