Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move SQLite base code #3790

Merged
merged 3 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/CheckpointManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace AppInstaller::Checkpoints
{
using namespace AppInstaller::CLI;
using namespace AppInstaller::Repository::Microsoft;
using namespace AppInstaller::Repository::SQLite;
using namespace AppInstaller::SQLite;

// This checkpoint name is reserved for the starting checkpoint which captures the automatic metadata.
constexpr std::string_view s_AutomaticCheckpoint = "automatic"sv;
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/PortableInstaller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ using namespace AppInstaller::Registry;
using namespace AppInstaller::Registry::Portable;
using namespace AppInstaller::Registry::Environment;
using namespace AppInstaller::Repository;
using namespace AppInstaller::Repository::SQLite;
using namespace AppInstaller::SQLite;
using namespace AppInstaller::Repository::Microsoft;
using namespace AppInstaller::Repository::Microsoft::Schema;

Expand Down
4 changes: 2 additions & 2 deletions src/AppInstallerCLICore/Workflows/PinFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#include "PinFlow.h"
#include "TableOutput.h"
#include "Microsoft/PinningIndex.h"
#include "Microsoft/SQLiteStorageBase.h"
#include <winget/SQLiteStorageBase.h>
#include "winget/RepositorySearch.h"

using namespace AppInstaller::Repository;
using namespace AppInstaller::Repository::Microsoft;
using namespace AppInstaller::SQLite;

namespace AppInstaller::CLI::Workflow
{
Expand Down
8 changes: 4 additions & 4 deletions src/AppInstallerCLITests/CheckpointDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using namespace std::string_literals;
using namespace TestCommon;
using namespace AppInstaller::Repository::Microsoft;
using namespace AppInstaller::Repository::SQLite;
using namespace AppInstaller::SQLite;
using namespace AppInstaller::Repository::Microsoft::Schema;
using namespace AppInstaller::Checkpoints;

Expand All @@ -17,19 +17,19 @@ TEST_CASE("CheckpointDatabaseCreateLatestAndReopen", "[checkpointDatabase]")
TempFile tempFile{ "repolibtest_tempdb"s, ".db"s };
INFO("Using temporary file named: " << tempFile.GetPath());

Schema::Version versionCreated;
Version versionCreated;

// Create the database
{
std::shared_ptr<CheckpointDatabase> database = CheckpointDatabase::CreateNew(tempFile, Schema::Version::Latest());
std::shared_ptr<CheckpointDatabase> database = CheckpointDatabase::CreateNew(tempFile, Version::Latest());
versionCreated = database->GetVersion();
}

// Reopen the database
{
INFO("Trying with ReadWrite");
std::shared_ptr<CheckpointDatabase> database = CheckpointDatabase::Open(tempFile, SQLiteStorageBase::OpenDisposition::ReadWrite);
Schema::Version versionRead = database->GetVersion();
Version versionRead = database->GetVersion();
REQUIRE(versionRead == versionCreated);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/AppInstallerCLITests/PackageTrackingCatalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ using namespace TestCommon;
using namespace AppInstaller::Manifest;
using namespace AppInstaller::Repository;
using namespace AppInstaller::Repository::Microsoft;
using namespace AppInstaller::Repository::SQLite;
using namespace AppInstaller::SQLite;
using namespace AppInstaller::Utility;

namespace
{
static Source SimpleTestSetup(const std::string& filePath, SourceDetails& details, Manifest& manifest, std::string& relativePath)
{
SQLiteIndex index = SQLiteIndex::CreateNew(filePath, Schema::Version::Latest(), SQLiteIndex::CreateOptions::SupportPathless | SQLiteIndex::CreateOptions::DisableDependenciesSupport);
SQLiteIndex index = SQLiteIndex::CreateNew(filePath, AppInstaller::SQLite::Version::Latest(), SQLiteIndex::CreateOptions::SupportPathless | SQLiteIndex::CreateOptions::DisableDependenciesSupport);

TestDataFile testManifest("Manifest-Good.yaml");
manifest = YamlParser::CreateFromPath(testManifest);
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCLITests/PinFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ using namespace AppInstaller::CLI::Workflow;
using namespace AppInstaller::Repository::Microsoft;
using namespace AppInstaller::Utility;
using namespace AppInstaller::Pinning;
using namespace AppInstaller::SQLite;

void OverrideForOpenPinningIndex(TestContext& context, const std::filesystem::path& indexPath)
{
Expand Down
12 changes: 6 additions & 6 deletions src/AppInstallerCLITests/PinningIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,43 @@ using namespace std::string_literals;
using namespace TestCommon;
using namespace AppInstaller::Pinning;
using namespace AppInstaller::Repository::Microsoft;
using namespace AppInstaller::Repository::SQLite;
using namespace AppInstaller::SQLite;
using namespace AppInstaller::Repository::Microsoft::Schema;

TEST_CASE("PinningIndexCreateLatestAndReopen", "[pinningIndex]")
{
TempFile tempFile{ "repolibtest_tempdb"s, ".db"s };
INFO("Using temporary file named: " << tempFile.GetPath());

Schema::Version versionCreated;
Version versionCreated;

// Create the index
{
PinningIndex index = PinningIndex::CreateNew(tempFile, Schema::Version::Latest());
PinningIndex index = PinningIndex::CreateNew(tempFile, Version::Latest());
versionCreated = index.GetVersion();
}

// Reopen the index for read only
{
INFO("Trying with Read");
PinningIndex index = PinningIndex::Open(tempFile, SQLiteStorageBase::OpenDisposition::Read);
Schema::Version versionRead = index.GetVersion();
Version versionRead = index.GetVersion();
REQUIRE(versionRead == versionCreated);
}

// Reopen the index for read/write
{
INFO("Trying with ReadWrite");
PinningIndex index = PinningIndex::Open(tempFile, SQLiteStorageBase::OpenDisposition::ReadWrite);
Schema::Version versionRead = index.GetVersion();
Version versionRead = index.GetVersion();
REQUIRE(versionRead == versionCreated);
}

// Reopen the index for immutable read
{
INFO("Trying with Immutable");
PinningIndex index = PinningIndex::Open(tempFile, SQLiteStorageBase::OpenDisposition::Immutable);
Schema::Version versionRead = index.GetVersion();
Version versionRead = index.GetVersion();
REQUIRE(versionRead == versionCreated);
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/AppInstallerCLITests/PortableIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Licensed under the MIT License.
#include "pch.h"
#include "TestCommon.h"
#include <SQLiteWrapper.h>
#include <Microsoft/SQLiteStorageBase.h>
#include <winget/SQLiteWrapper.h>
#include <winget/SQLiteStorageBase.h>
#include <Microsoft/Schema/IPortableIndex.h>
#include <Microsoft/PortableIndex.h>
#include <Microsoft/Schema/Portable_1_0/PortableTable.h>
Expand All @@ -13,7 +13,7 @@ using namespace std::string_literals;
using namespace TestCommon;
using namespace AppInstaller::Portable;
using namespace AppInstaller::Repository::Microsoft;
using namespace AppInstaller::Repository::SQLite;
using namespace AppInstaller::SQLite;
using namespace AppInstaller::Repository::Microsoft::Schema;

void CreateFakePortableFile(PortableFileEntry& file)
Expand All @@ -29,35 +29,35 @@ TEST_CASE("PortableIndexCreateLatestAndReopen", "[portableIndex]")
TempFile tempFile{ "repolibtest_tempdb"s, ".db"s };
INFO("Using temporary file named: " << tempFile.GetPath());

Schema::Version versionCreated;
Version versionCreated;

// Create the index
{
PortableIndex index = PortableIndex::CreateNew(tempFile, Schema::Version::Latest());
PortableIndex index = PortableIndex::CreateNew(tempFile, Version::Latest());
versionCreated = index.GetVersion();
}

// Reopen the index for read only
{
INFO("Trying with Read");
PortableIndex index = PortableIndex::Open(tempFile, SQLiteStorageBase::OpenDisposition::Read);
Schema::Version versionRead = index.GetVersion();
Version versionRead = index.GetVersion();
REQUIRE(versionRead == versionCreated);
}

// Reopen the index for read/write
{
INFO("Trying with ReadWrite");
PortableIndex index = PortableIndex::Open(tempFile, SQLiteStorageBase::OpenDisposition::ReadWrite);
Schema::Version versionRead = index.GetVersion();
Version versionRead = index.GetVersion();
REQUIRE(versionRead == versionCreated);
}

// Reopen the index for immutable read
{
INFO("Trying with Immutable");
PortableIndex index = PortableIndex::Open(tempFile, SQLiteStorageBase::OpenDisposition::Immutable);
Schema::Version versionRead = index.GetVersion();
Version versionRead = index.GetVersion();
REQUIRE(versionRead == versionCreated);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/AppInstallerCLITests/PortableInstaller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <winget/Manifest.h>
#include <winget/PathVariable.h>
#include <winget/PortableARPEntry.h>
#include <Microsoft/SQLiteStorageBase.h>
#include <winget/SQLiteStorageBase.h>
#include <Microsoft/Schema/IPortableIndex.h>
#include <Microsoft/PortableIndex.h>

Expand All @@ -18,7 +18,7 @@ using namespace AppInstaller::Filesystem;
using namespace AppInstaller::Manifest;
using namespace AppInstaller::Registry::Environment;
using namespace AppInstaller::Repository::Microsoft;
using namespace AppInstaller::Repository::SQLite;
using namespace AppInstaller::SQLite;
using namespace AppInstaller::Repository::Microsoft::Schema;
using namespace AppInstaller::Utility;
using namespace TestCommon;
Expand Down