Skip to content

Commit

Permalink
feat: Add some save data tests (#1623)
Browse files Browse the repository at this point in the history
* saving from a test works

* testing works

* Update SavingTests.cpp

* test dServer stuff

* tests

* use dummy database and add missing pure fns

* add more tests

* add more tests

* add rocket tests

* Update BuffComponent.h

* Update test_xml_data.xml

* Update SavingTests.cpp

* update
  • Loading branch information
EmosewaMC authored Nov 18, 2024
1 parent 008e2d4 commit adc9cd2
Show file tree
Hide file tree
Showing 16 changed files with 570 additions and 6 deletions.
8 changes: 7 additions & 1 deletion dDatabase/GameDatabase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ foreach(file ${DDATABSE_DATABSES_MYSQL_SOURCES})
set(DDATABASE_GAMEDATABASE_SOURCES ${DDATABASE_GAMEDATABASE_SOURCES} "MySQL/${file}")
endforeach()

add_subdirectory(TestSQL)

foreach(file ${DDATABSE_DATABSES_TEST_SQL_SOURCES})
set(DDATABASE_GAMEDATABASE_SOURCES ${DDATABASE_GAMEDATABASE_SOURCES} "TestSQL/${file}")
endforeach()

add_library(dDatabaseGame STATIC ${DDATABASE_GAMEDATABASE_SOURCES})
target_include_directories(dDatabaseGame PUBLIC "."
"ITables" PRIVATE "MySQL"
"ITables" PRIVATE "MySQL" "TestSQL"
"${PROJECT_SOURCE_DIR}/dCommon"
"${PROJECT_SOURCE_DIR}/dCommon/dEnums"
)
Expand Down
5 changes: 5 additions & 0 deletions dDatabase/GameDatabase/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ void Database::Destroy(std::string source) {
LOG("Trying to destroy database when it's not connected!");
}
}

void Database::_setDatabase(GameDatabase* const db) {
if (database) delete database;
database = db;
}
4 changes: 4 additions & 0 deletions dDatabase/GameDatabase/Database.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ namespace Database {
void Connect();
GameDatabase* Get();
void Destroy(std::string source = "");

// Used for assigning a test database as the handler for database logic.
// Do not use in production code.
void _setDatabase(GameDatabase* const db);
};
4 changes: 4 additions & 0 deletions dDatabase/GameDatabase/TestSQL/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SET(DDATABSE_DATABSES_TEST_SQL_SOURCES
"TestSQLDatabase.cpp"
PARENT_SCOPE
)
306 changes: 306 additions & 0 deletions dDatabase/GameDatabase/TestSQL/TestSQLDatabase.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,306 @@
#include "TestSQLDatabase.h"

void TestSQLDatabase::Connect() {

}

void TestSQLDatabase::Destroy(std::string source) {

}

sql::PreparedStatement* TestSQLDatabase::CreatePreppedStmt(const std::string& query) {
return nullptr;
}

void TestSQLDatabase::Commit() {

}

bool TestSQLDatabase::GetAutoCommit() {
return {};
}

void TestSQLDatabase::SetAutoCommit(bool value) {

}

void TestSQLDatabase::ExecuteCustomQuery(const std::string_view query) {

}

std::optional<IServers::MasterInfo> TestSQLDatabase::GetMasterInfo() {
return {};
}

std::vector<std::string> TestSQLDatabase::GetApprovedCharacterNames() {
return {};
}

std::vector<FriendData> TestSQLDatabase::GetFriendsList(uint32_t charID) {
return {};
}

std::optional<IFriends::BestFriendStatus> TestSQLDatabase::GetBestFriendStatus(const uint32_t playerCharacterId, const uint32_t friendCharacterId) {
return {};
}

void TestSQLDatabase::SetBestFriendStatus(const uint32_t playerAccountId, const uint32_t friendAccountId, const uint32_t bestFriendStatus) {

}

void TestSQLDatabase::AddFriend(const uint32_t playerAccountId, const uint32_t friendAccountId) {

}

void TestSQLDatabase::RemoveFriend(const uint32_t playerAccountId, const uint32_t friendAccountId) {

}

void TestSQLDatabase::UpdateActivityLog(const uint32_t characterId, const eActivityType activityType, const LWOMAPID mapId) {

}

void TestSQLDatabase::DeleteUgcModelData(const LWOOBJID& modelId) {

}

void TestSQLDatabase::UpdateUgcModelData(const LWOOBJID& modelId, std::istringstream& lxfml) {

}

std::vector<IUgc::Model> TestSQLDatabase::GetAllUgcModels() {
return {};
}

void TestSQLDatabase::CreateMigrationHistoryTable() {

}

bool TestSQLDatabase::IsMigrationRun(const std::string_view str) {
return {};
}

void TestSQLDatabase::InsertMigration(const std::string_view str) {

}

std::optional<ICharInfo::Info> TestSQLDatabase::GetCharacterInfo(const uint32_t charId) {
return {};
}

std::optional<ICharInfo::Info> TestSQLDatabase::GetCharacterInfo(const std::string_view charId) {
return {};
}

std::string TestSQLDatabase::GetCharacterXml(const uint32_t accountId) {
return {};
}

void TestSQLDatabase::UpdateCharacterXml(const uint32_t characterId, const std::string_view lxfml) {

}

std::optional<IAccounts::Info> TestSQLDatabase::GetAccountInfo(const std::string_view username) {
return {};
}

void TestSQLDatabase::InsertNewCharacter(const ICharInfo::Info info) {

}

void TestSQLDatabase::InsertCharacterXml(const uint32_t accountId, const std::string_view lxfml) {

}

std::vector<uint32_t> TestSQLDatabase::GetAccountCharacterIds(uint32_t accountId) {
return {};
}

void TestSQLDatabase::DeleteCharacter(const uint32_t characterId) {

}

void TestSQLDatabase::SetCharacterName(const uint32_t characterId, const std::string_view name) {

}

void TestSQLDatabase::SetPendingCharacterName(const uint32_t characterId, const std::string_view name) {

}

void TestSQLDatabase::UpdateLastLoggedInCharacter(const uint32_t characterId) {

}

void TestSQLDatabase::SetPetNameModerationStatus(const LWOOBJID& petId, const IPetNames::Info& info) {

}

std::optional<IPetNames::Info> TestSQLDatabase::GetPetNameInfo(const LWOOBJID& petId) {
return {};
}

std::optional<IProperty::Info> TestSQLDatabase::GetPropertyInfo(const LWOMAPID mapId, const LWOCLONEID cloneId) {
return {};
}

void TestSQLDatabase::UpdatePropertyModerationInfo(const IProperty::Info& info) {

}

void TestSQLDatabase::UpdatePropertyDetails(const IProperty::Info& info) {

}

void TestSQLDatabase::InsertNewProperty(const IProperty::Info& info, const uint32_t templateId, const LWOZONEID& zoneId) {

}

std::vector<IPropertyContents::Model> TestSQLDatabase::GetPropertyModels(const LWOOBJID& propertyId) {
return {};
}

void TestSQLDatabase::RemoveUnreferencedUgcModels() {

}

void TestSQLDatabase::InsertNewPropertyModel(const LWOOBJID& propertyId, const IPropertyContents::Model& model, const std::string_view name) {

}

void TestSQLDatabase::UpdateModel(const LWOOBJID& propertyId, const NiPoint3& position, const NiQuaternion& rotation, const std::array<std::pair<int32_t, std::string>, 5>& behaviors) {

}

void TestSQLDatabase::RemoveModel(const LWOOBJID& modelId) {

}

void TestSQLDatabase::UpdatePerformanceCost(const LWOZONEID& zoneId, const float performanceCost) {

}

void TestSQLDatabase::InsertNewBugReport(const IBugReports::Info& info) {

}

void TestSQLDatabase::InsertCheatDetection(const IPlayerCheatDetections::Info& info) {

}

void TestSQLDatabase::InsertNewMail(const IMail::MailInfo& mail) {

}

void TestSQLDatabase::InsertNewUgcModel(std::istringstream& sd0Data, const uint32_t blueprintId, const uint32_t accountId, const uint32_t characterId) {

}

std::vector<IMail::MailInfo> TestSQLDatabase::GetMailForPlayer(const uint32_t characterId, const uint32_t numberOfMail) {
return {};
}

std::optional<IMail::MailInfo> TestSQLDatabase::GetMail(const uint64_t mailId) {
return {};
}

uint32_t TestSQLDatabase::GetUnreadMailCount(const uint32_t characterId) {
return {};
}

void TestSQLDatabase::MarkMailRead(const uint64_t mailId) {

}

void TestSQLDatabase::DeleteMail(const uint64_t mailId) {

}

void TestSQLDatabase::ClaimMailItem(const uint64_t mailId) {

}

void TestSQLDatabase::InsertSlashCommandUsage(const uint32_t characterId, const std::string_view command) {

}

void TestSQLDatabase::UpdateAccountUnmuteTime(const uint32_t accountId, const uint64_t timeToUnmute) {

}

void TestSQLDatabase::UpdateAccountBan(const uint32_t accountId, const bool banned) {

}

void TestSQLDatabase::UpdateAccountPassword(const uint32_t accountId, const std::string_view bcryptpassword) {

}

void TestSQLDatabase::InsertNewAccount(const std::string_view username, const std::string_view bcryptpassword) {

}

void TestSQLDatabase::SetMasterIp(const std::string_view ip, const uint32_t port) {

}

std::optional<uint32_t> TestSQLDatabase::GetCurrentPersistentId() {
return {};
}

void TestSQLDatabase::InsertDefaultPersistentId() {

}

void TestSQLDatabase::UpdatePersistentId(const uint32_t id) {

}

std::optional<uint32_t> TestSQLDatabase::GetDonationTotal(const uint32_t activityId) {
return {};
}

std::optional<bool> TestSQLDatabase::IsPlaykeyActive(const int32_t playkeyId) {
return {};
}

std::vector<IUgc::Model> TestSQLDatabase::GetUgcModels(const LWOOBJID& propertyId) {
return {};
}

void TestSQLDatabase::AddIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) {

}

void TestSQLDatabase::RemoveIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) {

}

std::vector<IIgnoreList::Info> TestSQLDatabase::GetIgnoreList(const uint32_t playerId) {
return {};
}

void TestSQLDatabase::InsertRewardCode(const uint32_t account_id, const uint32_t reward_code) {

}

std::vector<uint32_t> TestSQLDatabase::GetRewardCodesByAccountID(const uint32_t account_id) {
return {};
}

void TestSQLDatabase::AddBehavior(const IBehaviors::Info& info) {

}

std::string TestSQLDatabase::GetBehavior(const int32_t behaviorId) {
return {};
}

void TestSQLDatabase::RemoveBehavior(const int32_t behaviorId) {

}

void TestSQLDatabase::UpdateAccountGmLevel(const uint32_t accountId, const eGameMasterLevel gmLevel) {

}

Loading

0 comments on commit adc9cd2

Please sign in to comment.