-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MultiDB]:swsscommon replace old API with new APIs including tests (#324
) * [MultiDB]:swsscommon replace old API with new APIs including tests * update code format * move db setup into global setup
- Loading branch information
1 parent
29a2cdf
commit 838d9b4
Showing
18 changed files
with
154 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include "gtest/gtest.h" | ||
#include "common/dbconnector.h" | ||
#include <iostream> | ||
|
||
using namespace std; | ||
using namespace swss; | ||
|
||
string existing_file = "./tests/redis_multi_db_ut_config/database_config.json"; | ||
string nonexisting_file = "./tests/redis_multi_db_ut_config/database_config_nonexisting.json"; | ||
|
||
class SwsscommonEnvironment : public ::testing::Environment { | ||
public: | ||
// Override this to define how to set up the environment. | ||
void SetUp() override { | ||
// by default , init should be false | ||
cout<<"Default : isInit = "<<SonicDBConfig::isInit()<<endl; | ||
EXPECT_FALSE(SonicDBConfig::isInit()); | ||
|
||
// load nonexisting file, should throw exception with NO file existing | ||
try | ||
{ | ||
cout<<"INIT: loading nonexisting db config file"<<endl; | ||
SonicDBConfig::initialize(nonexisting_file); | ||
} | ||
catch (exception &e) | ||
{ | ||
EXPECT_TRUE(strstr(e.what(), "Sonic database config file doesn't exist")); | ||
} | ||
EXPECT_FALSE(SonicDBConfig::isInit()); | ||
|
||
// load local config file, init should be true | ||
SonicDBConfig::initialize(existing_file); | ||
cout<<"INIT: load local db config file, isInit = "<<SonicDBConfig::isInit()<<endl; | ||
EXPECT_TRUE(SonicDBConfig::isInit()); | ||
} | ||
}; | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
testing::InitGoogleTest(&argc, argv); | ||
// Registers a global test environment, and verifies that the | ||
// registration function returns its argument. | ||
SwsscommonEnvironment* const env = new SwsscommonEnvironment; | ||
testing::AddGlobalTestEnvironment(env); | ||
return RUN_ALL_TESTS(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.