forked from microsoft/winget-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQLiteDynamicStorage.cpp
More file actions
43 lines (34 loc) · 1.38 KB
/
Copy pathSQLiteDynamicStorage.cpp
File metadata and controls
43 lines (34 loc) · 1.38 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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "pch.h"
#include "TestCommon.h"
#include <AppInstallerErrors.h>
#include <winget/SQLiteDynamicStorage.h>
#include <winget/SQLiteWrapper.h>
#include <winget/SQLiteStatementBuilder.h>
#include <winget/SQLiteVersion.h>
using namespace AppInstaller::SQLite;
using namespace std::string_literals;
TEST_CASE("SQLiteDynamicStorage_UpgradeDetection", "[sqlite_dynamic]")
{
TestCommon::TempFile tempFile{ "repolibtest_tempdb"s, ".db"s };
INFO("Using temporary file named: " << tempFile.GetPath());
// Create a database with version 1.0
SQLiteDynamicStorage storage{ tempFile.GetPath(), Version{ 1, 0 } };
{
auto transactionLock = storage.TryBeginTransaction("test", false);
REQUIRE(transactionLock);
}
// Update the database to version 2.0
{
Connection connection = Connection::Create(tempFile, Connection::OpenDisposition::Create);
Version version{ 2, 0 };
version.SetSchemaVersion(connection);
}
REQUIRE(storage.GetVersion() == Version{ 1, 0 });
auto transactionLock = storage.TryBeginTransaction("test", false);
REQUIRE(!transactionLock);
REQUIRE(storage.GetVersion() == Version{ 2, 0 });
transactionLock = storage.TryBeginTransaction("test", false);
REQUIRE(transactionLock);
}