+
+TEST_F(DatabaseConfigurationImplTest, DefaultSentinelAddressIsNone)
+{
+ EXPECT_EQ(boost::none, databaseConfigurationImpl->getSentinelAddress(boost::none));
+}
+
+TEST_F(DatabaseConfigurationImplTest, CanApplyAndReturnSentinelAddress)
+{
+ databaseConfigurationImpl->checkAndApplySentinelAddress("dummydatabaseaddress.local:1234");
+ auto address = databaseConfigurationImpl->getSentinelAddress(boost::none);
+ EXPECT_NE(boost::none, databaseConfigurationImpl->getSentinelAddress(boost::none));
+ EXPECT_EQ("dummydatabaseaddress.local", address->getHost());
+ EXPECT_EQ(1234, ntohs(address->getPort()));
+}
+
+TEST_F(DatabaseConfigurationImplTest, DefaultSentinelMasterNameIsEmpty)
+{
+ EXPECT_EQ("", databaseConfigurationImpl->getSentinelMasterName());
+}
+
+TEST_F(DatabaseConfigurationImplTest, CanApplyAndReturnSentinelMasterName)
+{
+ databaseConfigurationImpl->checkAndApplySentinelMasterName("mymaster");
+ EXPECT_EQ("mymaster", databaseConfigurationImpl->getSentinelMasterName());
+}
+
+TEST_F(DatabaseConfigurationImplTest, CanReturnSDLSentinelClusterAddress)
+{
+ databaseConfigurationImpl->checkAndApplyDbType("sdl-sentinel-cluster");
+ databaseConfigurationImpl->checkAndApplyServerAddress("cluster-0.local");
+ databaseConfigurationImpl->checkAndApplyServerAddress("cluster-1.local");
+ databaseConfigurationImpl->checkAndApplyServerAddress("cluster-2.local");
+ databaseConfigurationImpl->checkAndApplySentinelAddress("cluster-0.local:54321");
+ auto address0 = databaseConfigurationImpl->getSentinelAddress(0);
+ auto address1 = databaseConfigurationImpl->getSentinelAddress(1);
+ auto address2 = databaseConfigurationImpl->getSentinelAddress(2);
+ EXPECT_NE(boost::none, databaseConfigurationImpl->getSentinelAddress(0));
+ EXPECT_NE(boost::none, databaseConfigurationImpl->getSentinelAddress(1));
+ EXPECT_NE(boost::none, databaseConfigurationImpl->getSentinelAddress(2));
+ EXPECT_EQ("cluster-0.local", address0->getHost());
+ EXPECT_EQ("cluster-1.local", address1->getHost());
+ EXPECT_EQ("cluster-2.local", address2->getHost());
+ EXPECT_EQ(54321, ntohs(address0->getPort()));
+}
+
+TEST_F(DatabaseConfigurationImplTest, CanReturnDefaultPortForSDLClusterAddress)
+{
+ databaseConfigurationImpl->checkAndApplyServerAddress("cluster-0.local");
+ databaseConfigurationImpl->checkAndApplySentinelAddress("cluster-0.local");
+ auto address0 = databaseConfigurationImpl->getSentinelAddress(0);
+ EXPECT_NE(boost::none, databaseConfigurationImpl->getSentinelAddress(0));
+ EXPECT_EQ("cluster-0.local", address0->getHost());
+ EXPECT_EQ(26379, ntohs(address0->getPort()));
+}