mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-12-05 12:52:00 +00:00
The macOS update feed moves from GitHub Pages to the orcaslicer_updater worker's Cloudflare KV, served at https://check-version.orcaslicer.com/appcast.xml. publish_appcast.yml uploads the generated feed to the KV namespace instead of pushing to gh-pages, and version.inc advertises the new URL. The Nightly channel is removed everywhere: UpdateChannel::Nightly and its resolver branches, the Preferences option, the helper and GUI labels, the skip_artifact setting, the nightly appcast CI job, and the docs. Only Stable and Pre-Release remain; a -dev version counts as Pre-Release.
873 lines
36 KiB
C++
873 lines
36 KiB
C++
#include <catch2/catch_all.hpp>
|
|
|
|
#include <string>
|
|
|
|
#include "catch2/catch_test_macros.hpp"
|
|
#include "libslic3r/UpdateChannel.hpp"
|
|
|
|
using namespace Slic3r;
|
|
|
|
namespace {
|
|
|
|
// Two stable releases plus the rolling nightly one, in the order the service
|
|
// returns them: the picker must not simply take the first entry.
|
|
const char* stable_releases_json()
|
|
{
|
|
return R"JSON([
|
|
{
|
|
"tag_name": "v2.4.0",
|
|
"prerelease": false,
|
|
"html_url": "https://example.invalid/releases/v2.4.0",
|
|
"body": "older release",
|
|
"updated_at": "2026-06-01T10:00:00Z",
|
|
"assets": [
|
|
{
|
|
"name": "OrcaSlicer_Windows_Installer_V2.4.0_x64.exe",
|
|
"browser_download_url": "https://example.invalid/OrcaSlicer_Windows_Installer_V2.4.0_x64.exe",
|
|
"digest": "sha256:1111",
|
|
"size": 100
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"tag_name": "v2.5.0",
|
|
"prerelease": false,
|
|
"html_url": "https://example.invalid/releases/v2.5.0",
|
|
"body": "newer release",
|
|
"updated_at": "2026-10-01T10:00:00Z",
|
|
"assets": [
|
|
{
|
|
"name": "OrcaSlicer_Windows_Installer_V2.5.0_x64.exe",
|
|
"browser_download_url": "https://example.invalid/OrcaSlicer_Windows_Installer_V2.5.0_x64.exe",
|
|
"digest": "sha256:2222",
|
|
"size": 200
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"tag_name": "nightly-builds",
|
|
"prerelease": true,
|
|
"html_url": "https://example.invalid/releases/nightly-builds",
|
|
"body": "nightly release",
|
|
"updated_at": "2026-11-10T08:31:54Z",
|
|
"assets": [
|
|
{
|
|
"name": "OrcaSlicer_Windows_Installer_x64_nightly.exe",
|
|
"browser_download_url": "https://example.invalid/OrcaSlicer_Windows_Installer_x64_nightly.exe",
|
|
"digest": "sha256:nightly2",
|
|
"size": 300
|
|
}
|
|
]
|
|
}
|
|
])JSON";
|
|
}
|
|
|
|
// The release lists the discontinued _belt AppImage before the main one.
|
|
const char* belt_first_releases_json()
|
|
{
|
|
return R"JSON([
|
|
{
|
|
"tag_name": "v2.5.0",
|
|
"prerelease": false,
|
|
"html_url": "https://example.invalid/releases/v2.5.0",
|
|
"body": "2.5.0",
|
|
"updated_at": "2026-10-01T10:00:00Z",
|
|
"assets": [
|
|
{
|
|
"name": "OrcaSlicer_Linux_AppImage_Ubuntu2404_V2.5.0_belt.AppImage",
|
|
"browser_download_url": "https://example.invalid/OrcaSlicer_Linux_AppImage_Ubuntu2404_V2.5.0_belt.AppImage",
|
|
"digest": "sha256:belt",
|
|
"size": 310
|
|
},
|
|
{
|
|
"name": "OrcaSlicer_Linux_AppImage_Ubuntu2404_V2.5.0.AppImage",
|
|
"browser_download_url": "https://example.invalid/OrcaSlicer_Linux_AppImage_Ubuntu2404_V2.5.0.AppImage",
|
|
"digest": "sha256:2500",
|
|
"size": 300
|
|
}
|
|
]
|
|
}
|
|
])JSON";
|
|
}
|
|
|
|
const char* belt_only_releases_json()
|
|
{
|
|
return R"JSON([
|
|
{
|
|
"tag_name": "v2.5.0",
|
|
"prerelease": false,
|
|
"html_url": "https://example.invalid/releases/v2.5.0",
|
|
"body": "2.5.0",
|
|
"updated_at": "2026-10-01T10:00:00Z",
|
|
"assets": [
|
|
{
|
|
"name": "OrcaSlicer_Linux_AppImage_Ubuntu2404_V2.5.0_belt.AppImage",
|
|
"browser_download_url": "https://example.invalid/OrcaSlicer_Linux_AppImage_Ubuntu2404_V2.5.0_belt.AppImage",
|
|
"digest": "sha256:belt",
|
|
"size": 310
|
|
}
|
|
]
|
|
}
|
|
])JSON";
|
|
}
|
|
|
|
// A stable release whose only asset carries no digest.
|
|
const char* stable_release_without_digest_json()
|
|
{
|
|
return R"JSON([
|
|
{
|
|
"tag_name": "v2.5.0",
|
|
"prerelease": false,
|
|
"html_url": "https://example.invalid/releases/v2.5.0",
|
|
"body": "newer release",
|
|
"updated_at": "2026-10-01T10:00:00Z",
|
|
"assets": [
|
|
{
|
|
"name": "OrcaSlicer_Windows_Installer_V2.5.0_x64.exe",
|
|
"browser_download_url": "https://example.invalid/OrcaSlicer_Windows_Installer_V2.5.0_x64.exe",
|
|
"size": 200
|
|
}
|
|
]
|
|
}
|
|
])JSON";
|
|
}
|
|
|
|
// The shape the service returns while 2.6.0 is in flight: the final release, the
|
|
// rolling nightly and the three prereleases, deliberately not in version order. The
|
|
// final release sorts above every prerelease, so both Stable and Pre-Release offer it.
|
|
const char* prerelease_releases_json()
|
|
{
|
|
return R"JSON([
|
|
{
|
|
"tag_name": "v2.6.0",
|
|
"prerelease": false,
|
|
"html_url": "https://example.invalid/releases/v2.6.0",
|
|
"body": "2.6.0",
|
|
"updated_at": "2026-11-20T10:00:00Z",
|
|
"assets": [
|
|
{
|
|
"name": "OrcaSlicer_Windows_Installer_V2.6.0_x64.exe",
|
|
"browser_download_url": "https://example.invalid/OrcaSlicer_Windows_Installer_V2.6.0_x64.exe",
|
|
"digest": "sha256:2600",
|
|
"size": 400
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"tag_name": "nightly-builds",
|
|
"prerelease": true,
|
|
"html_url": "https://example.invalid/releases/nightly-builds",
|
|
"body": "nightly release",
|
|
"updated_at": "2026-11-10T08:31:54Z",
|
|
"assets": [
|
|
{
|
|
"name": "OrcaSlicer_Windows_Installer_x64_nightly.exe",
|
|
"browser_download_url": "https://example.invalid/OrcaSlicer_Windows_Installer_x64_nightly.exe",
|
|
"digest": "sha256:nightly2",
|
|
"size": 350
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"tag_name": "v2.6.0-beta",
|
|
"prerelease": true,
|
|
"html_url": "https://example.invalid/releases/v2.6.0-beta",
|
|
"body": "2.6.0 beta",
|
|
"updated_at": "2026-10-27T17:22:32Z",
|
|
"assets": [
|
|
{
|
|
"name": "OrcaSlicer_Windows_Installer_V2.6.0-beta_x64.exe",
|
|
"browser_download_url": "https://example.invalid/OrcaSlicer_Windows_Installer_V2.6.0-beta_x64.exe",
|
|
"digest": "sha256:2600beta",
|
|
"size": 390
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"tag_name": "v2.6.0-rc",
|
|
"prerelease": true,
|
|
"html_url": "https://example.invalid/releases/v2.6.0-rc",
|
|
"body": "2.6.0 release candidate",
|
|
"updated_at": "2026-11-01T10:36:26Z",
|
|
"assets": [
|
|
{
|
|
"name": "OrcaSlicer_Windows_Installer_V2.6.0-rc_x64.exe",
|
|
"browser_download_url": "https://example.invalid/OrcaSlicer_Windows_Installer_V2.6.0-rc_x64.exe",
|
|
"digest": "sha256:2600rc",
|
|
"size": 395
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"tag_name": "v2.6.0-alpha",
|
|
"prerelease": true,
|
|
"html_url": "https://example.invalid/releases/v2.6.0-alpha",
|
|
"body": "2.6.0 alpha",
|
|
"updated_at": "2026-10-16T14:28:11Z",
|
|
"assets": [
|
|
{
|
|
"name": "OrcaSlicer_Windows_Installer_V2.6.0-alpha_x64.exe",
|
|
"browser_download_url": "https://example.invalid/OrcaSlicer_Windows_Installer_V2.6.0-alpha_x64.exe",
|
|
"digest": "sha256:2600alpha",
|
|
"size": 380
|
|
}
|
|
]
|
|
}
|
|
])JSON";
|
|
}
|
|
|
|
// The state right after a final ships, before the next cycle opens: a stable build and a
|
|
// prerelease of the next version.
|
|
const char* newer_prerelease_release_json()
|
|
{
|
|
return R"JSON([
|
|
{
|
|
"tag_name": "v2.6.0",
|
|
"prerelease": false,
|
|
"html_url": "https://example.invalid/releases/v2.6.0",
|
|
"body": "2.6.0",
|
|
"updated_at": "2026-11-20T10:00:00Z",
|
|
"assets": [
|
|
{
|
|
"name": "OrcaSlicer_Windows_Installer_V2.6.0_x64.exe",
|
|
"browser_download_url": "https://example.invalid/OrcaSlicer_Windows_Installer_V2.6.0_x64.exe",
|
|
"digest": "sha256:2600",
|
|
"size": 400
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"tag_name": "v2.7.0-alpha",
|
|
"prerelease": true,
|
|
"html_url": "https://example.invalid/releases/v2.7.0-alpha",
|
|
"body": "2.7.0 alpha",
|
|
"updated_at": "2026-12-02T09:00:00Z",
|
|
"assets": [
|
|
{
|
|
"name": "OrcaSlicer_Windows_Installer_V2.7.0-alpha_x64.exe",
|
|
"browser_download_url": "https://example.invalid/OrcaSlicer_Windows_Installer_V2.7.0-alpha_x64.exe",
|
|
"digest": "sha256:2700alpha",
|
|
"size": 410
|
|
}
|
|
]
|
|
}
|
|
])JSON";
|
|
}
|
|
|
|
// The 2.7.0 alpha was published without the release page's prerelease checkbox, so only
|
|
// its tag says what it is.
|
|
const char* unflagged_prerelease_release_json()
|
|
{
|
|
return R"JSON([
|
|
{
|
|
"tag_name": "v2.6.0",
|
|
"prerelease": false,
|
|
"html_url": "https://example.invalid/releases/v2.6.0",
|
|
"body": "2.6.0",
|
|
"updated_at": "2026-11-20T10:00:00Z",
|
|
"assets": [
|
|
{
|
|
"name": "OrcaSlicer_Windows_Installer_V2.6.0_x64.exe",
|
|
"browser_download_url": "https://example.invalid/OrcaSlicer_Windows_Installer_V2.6.0_x64.exe",
|
|
"digest": "sha256:2600",
|
|
"size": 400
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"tag_name": "v2.7.0-alpha",
|
|
"prerelease": false,
|
|
"html_url": "https://example.invalid/releases/v2.7.0-alpha",
|
|
"body": "2.7.0 alpha",
|
|
"updated_at": "2026-12-02T09:00:00Z",
|
|
"assets": [
|
|
{
|
|
"name": "OrcaSlicer_Windows_Installer_V2.7.0-alpha_x64.exe",
|
|
"browser_download_url": "https://example.invalid/OrcaSlicer_Windows_Installer_V2.7.0-alpha_x64.exe",
|
|
"digest": "sha256:2700alpha",
|
|
"size": 410
|
|
}
|
|
]
|
|
}
|
|
])JSON";
|
|
}
|
|
|
|
// v2.3.2-rc shipped its assets with the suffix spelled in upper case.
|
|
const char* mixed_case_asset_release_json()
|
|
{
|
|
return R"JSON([
|
|
{
|
|
"tag_name": "v2.3.2-rc",
|
|
"prerelease": true,
|
|
"html_url": "https://example.invalid/releases/v2.3.2-rc",
|
|
"body": "2.3.2 rc",
|
|
"updated_at": "2026-03-01T13:59:35Z",
|
|
"assets": [
|
|
{
|
|
"name": "OrcaSlicer_Windows_Installer_V2.3.2-RC_x64.exe",
|
|
"browser_download_url": "https://example.invalid/OrcaSlicer_Windows_Installer_V2.3.2-RC_x64.exe",
|
|
"digest": "sha256:232rc",
|
|
"size": 300
|
|
}
|
|
]
|
|
}
|
|
])JSON";
|
|
}
|
|
|
|
// A stable release shipping both the Windows installer and the portable zip.
|
|
const char* stable_portable_release_json()
|
|
{
|
|
return R"JSON([
|
|
{
|
|
"tag_name": "v2.5.0",
|
|
"prerelease": false,
|
|
"html_url": "https://example.invalid/releases/v2.5.0",
|
|
"body": "newer release",
|
|
"updated_at": "2026-10-01T10:00:00Z",
|
|
"assets": [
|
|
{
|
|
"name": "OrcaSlicer_Windows_Installer_V2.5.0_x64.exe",
|
|
"browser_download_url": "https://example.invalid/OrcaSlicer_Windows_Installer_V2.5.0_x64.exe",
|
|
"digest": "sha256:2222",
|
|
"size": 200
|
|
},
|
|
{
|
|
"name": "OrcaSlicer_Windows_portable_V2.5.0_x64.zip",
|
|
"browser_download_url": "https://example.invalid/OrcaSlicer_Windows_portable_V2.5.0_x64.zip",
|
|
"digest": "sha256:2222portable",
|
|
"size": 210
|
|
}
|
|
]
|
|
}
|
|
])JSON";
|
|
}
|
|
|
|
// A stable release newer than the -dev version a nightly build reports.
|
|
const char* stable_after_dev_release_json()
|
|
{
|
|
return R"JSON([
|
|
{
|
|
"tag_name": "v2.6.1",
|
|
"prerelease": false,
|
|
"html_url": "https://example.invalid/releases/v2.6.1",
|
|
"body": "2.6.1",
|
|
"updated_at": "2026-11-25T10:00:00Z",
|
|
"assets": [
|
|
{
|
|
"name": "OrcaSlicer_Windows_Installer_V2.6.1_x64.exe",
|
|
"browser_download_url": "https://example.invalid/OrcaSlicer_Windows_Installer_V2.6.1_x64.exe",
|
|
"digest": "sha256:2610",
|
|
"size": 420
|
|
}
|
|
]
|
|
}
|
|
])JSON";
|
|
}
|
|
|
|
} // namespace
|
|
|
|
TEST_CASE("A stable release newer than the running version is offered", "[UpdateChannel]")
|
|
{
|
|
const UpdateCandidate candidate = resolve_update(stable_releases_json(), UpdateChannel::Stable, "", "",
|
|
"2.4.9", InstallFlavour::WindowsInstaller, "x86_64");
|
|
|
|
CHECK(candidate.available);
|
|
CHECK(candidate.reason.empty());
|
|
CHECK(candidate.channel == UpdateChannel::Stable);
|
|
CHECK(candidate.version == "2.5.0");
|
|
CHECK(candidate.version_label == "2.5.0");
|
|
CHECK(candidate.release_url == "https://example.invalid/releases/v2.5.0");
|
|
CHECK(candidate.release_notes == "newer release");
|
|
CHECK(candidate.asset.name == "OrcaSlicer_Windows_Installer_V2.5.0_x64.exe");
|
|
CHECK(candidate.asset.digest == "sha256:2222");
|
|
CHECK(candidate.asset.size == 200);
|
|
}
|
|
|
|
TEST_CASE("A stable release equal to the running version is not offered", "[UpdateChannel]")
|
|
{
|
|
const UpdateCandidate candidate = resolve_update(stable_releases_json(), UpdateChannel::Stable, "", "",
|
|
"2.5.0", InstallFlavour::WindowsInstaller, "x86_64");
|
|
|
|
CHECK_FALSE(candidate.available);
|
|
CHECK(candidate.reason == "up_to_date");
|
|
CHECK(candidate.version == "2.5.0");
|
|
}
|
|
|
|
TEST_CASE("A body that is not a release list is reported as unreadable, not as no release", "[UpdateChannel]")
|
|
{
|
|
for (const char* body : { "<html>a proxy's page</html>", "{\"message\":\"rate limited\"}", "" }) {
|
|
const UpdateCandidate candidate = resolve_update(body, UpdateChannel::Stable, "", "", "2.4.9",
|
|
InstallFlavour::WindowsInstaller, "x86_64");
|
|
|
|
CHECK_FALSE(candidate.available);
|
|
CHECK(candidate.reason == "unreadable");
|
|
}
|
|
}
|
|
|
|
TEST_CASE("A hand-installed dev build is not downgraded by the channel it infers", "[UpdateChannel]")
|
|
{
|
|
// Nothing recorded its channel, so Stable reads the running dev build as a pre-release and
|
|
// treats the check as a channel switch. 2.5.0 sorts below the running build, so it is not offered.
|
|
const UpdateCandidate candidate = resolve_update(stable_releases_json(), UpdateChannel::Stable, "", "",
|
|
"2.6.0-dev", InstallFlavour::WindowsInstaller, "x86_64");
|
|
|
|
CHECK_FALSE(candidate.available);
|
|
CHECK(candidate.reason == "up_to_date");
|
|
CHECK(candidate.version == "2.5.0");
|
|
}
|
|
|
|
TEST_CASE("A hand-installed prerelease is not downgraded by the channel it infers", "[UpdateChannel]")
|
|
{
|
|
// No recorded channel, so Stable reads the running 2.6.0-rc1 as a prerelease and treats the
|
|
// check as a channel switch: 2.5.0 sorts below the running build, so it is not offered.
|
|
const UpdateCandidate candidate = resolve_update(stable_releases_json(), UpdateChannel::Stable, "", "",
|
|
"2.6.0-rc1", InstallFlavour::WindowsInstaller, "x86_64");
|
|
|
|
CHECK_FALSE(candidate.available);
|
|
CHECK(candidate.reason == "up_to_date");
|
|
CHECK(candidate.version == "2.5.0");
|
|
}
|
|
|
|
TEST_CASE("A hand-installed prerelease is offered the stable release of its own version", "[UpdateChannel]")
|
|
{
|
|
const UpdateCandidate candidate = resolve_update(newer_prerelease_release_json(), UpdateChannel::Stable, "", "",
|
|
"2.6.0-rc1", InstallFlavour::WindowsInstaller, "x86_64");
|
|
|
|
CHECK(candidate.available);
|
|
CHECK(candidate.reason == "channel_switch");
|
|
CHECK(candidate.version == "2.6.0");
|
|
}
|
|
|
|
TEST_CASE("A hand-installed dev build is offered a newer stable release", "[UpdateChannel]")
|
|
{
|
|
const UpdateCandidate candidate = resolve_update(stable_after_dev_release_json(), UpdateChannel::Stable, "", "",
|
|
"2.6.0-dev", InstallFlavour::WindowsInstaller, "x86_64");
|
|
|
|
CHECK(candidate.available);
|
|
CHECK(candidate.reason == "channel_switch");
|
|
CHECK(candidate.version == "2.6.1");
|
|
}
|
|
|
|
TEST_CASE("A hand-installed build whose version cannot be compared is not switched", "[UpdateChannel]")
|
|
{
|
|
// Nothing recorded the channel and the version does not parse, so it belongs to no channel
|
|
// an ordering could be checked against: the stable release is not offered, even though
|
|
// Stable is what the user selected.
|
|
const UpdateCandidate candidate = resolve_update(stable_releases_json(), UpdateChannel::Stable, "", "",
|
|
"dev build", InstallFlavour::WindowsInstaller, "x86_64");
|
|
|
|
CHECK_FALSE(candidate.available);
|
|
CHECK(candidate.reason == "up_to_date");
|
|
}
|
|
|
|
TEST_CASE("A recorded prerelease channel still switches to the stable channel", "[UpdateChannel]")
|
|
{
|
|
// The switch comes from the setting, not from the version: the stable artifact is offered
|
|
// even though it sorts below the running prerelease.
|
|
const UpdateCandidate candidate = resolve_update(stable_releases_json(), UpdateChannel::Stable,
|
|
"sha256:2600rc", "prerelease", "2.6.0-rc1",
|
|
InstallFlavour::WindowsInstaller, "x86_64");
|
|
|
|
CHECK(candidate.available);
|
|
CHECK(candidate.reason == "channel_switch");
|
|
CHECK(candidate.version == "2.5.0");
|
|
}
|
|
|
|
TEST_CASE("The channel of a version follows its suffix", "[UpdateChannel]")
|
|
{
|
|
// A dev build is a pre-release: it follows the newest release of any kind.
|
|
CHECK(channel_of_version("2.6.0-dev") == UpdateChannel::PreRelease);
|
|
CHECK(channel_of_version("2.6.0-rc1") == UpdateChannel::PreRelease);
|
|
CHECK(channel_of_version("2.6.0-beta") == UpdateChannel::PreRelease);
|
|
CHECK(channel_of_version("2.6.0-alpha") == UpdateChannel::PreRelease);
|
|
CHECK(channel_of_version("2.6.0") == UpdateChannel::Stable);
|
|
CHECK(channel_of_version("") == UpdateChannel::Stable);
|
|
CHECK(channel_of_version("garbage") == UpdateChannel::Stable);
|
|
}
|
|
|
|
TEST_CASE("The pre-release channel offers the final release when it is newer than every prerelease", "[UpdateChannel]")
|
|
{
|
|
const UpdateCandidate candidate = resolve_update(prerelease_releases_json(), UpdateChannel::PreRelease, "",
|
|
"", "2.5.0", InstallFlavour::WindowsInstaller, "x86_64");
|
|
|
|
CHECK(candidate.available);
|
|
CHECK(candidate.channel == UpdateChannel::PreRelease);
|
|
CHECK(candidate.version == "2.6.0");
|
|
CHECK(candidate.asset.name == "OrcaSlicer_Windows_Installer_V2.6.0_x64.exe");
|
|
CHECK(candidate.asset.digest == "sha256:2600");
|
|
}
|
|
|
|
TEST_CASE("The pre-release channel offers a prerelease newer than the newest final release", "[UpdateChannel]")
|
|
{
|
|
const UpdateCandidate candidate = resolve_update(newer_prerelease_release_json(), UpdateChannel::PreRelease, "",
|
|
"", "2.5.0", InstallFlavour::WindowsInstaller, "x86_64");
|
|
|
|
CHECK(candidate.available);
|
|
CHECK(candidate.version == "2.7.0-alpha");
|
|
}
|
|
|
|
TEST_CASE("The pre-release channel offers the newest final release when no prerelease exists", "[UpdateChannel]")
|
|
{
|
|
const UpdateCandidate candidate = resolve_update(stable_releases_json(), UpdateChannel::PreRelease, "", "",
|
|
"2.4.9", InstallFlavour::WindowsInstaller, "x86_64");
|
|
|
|
CHECK(candidate.available);
|
|
CHECK(candidate.version == "2.5.0");
|
|
}
|
|
|
|
TEST_CASE("Stable never offers a prerelease that outranks every final release", "[UpdateChannel]")
|
|
{
|
|
// 2.7.0-alpha sorts above the newest final, so a Stable check that saw it would offer it.
|
|
const UpdateCandidate candidate = resolve_update(newer_prerelease_release_json(), UpdateChannel::Stable, "",
|
|
"", "2.5.0", InstallFlavour::WindowsInstaller, "x86_64");
|
|
|
|
CHECK(candidate.available);
|
|
CHECK(candidate.version == "2.6.0");
|
|
}
|
|
|
|
TEST_CASE("Stable never offers a prerelease whose release flag was not set", "[UpdateChannel]")
|
|
{
|
|
// The tag alone says what it is: a checkbox ticked by hand must not be what keeps an alpha
|
|
// away from Stable.
|
|
const UpdateCandidate candidate = resolve_update(unflagged_prerelease_release_json(), UpdateChannel::Stable, "",
|
|
"", "2.5.0", InstallFlavour::WindowsInstaller, "x86_64");
|
|
|
|
CHECK(candidate.available);
|
|
CHECK(candidate.version == "2.6.0");
|
|
CHECK(candidate.asset.name == "OrcaSlicer_Windows_Installer_V2.6.0_x64.exe");
|
|
}
|
|
|
|
TEST_CASE("The pre-release channel offers nothing when the running build is the final release", "[UpdateChannel]")
|
|
{
|
|
// The newest release is the 2.6.0 final itself, so nothing is newer than the running build.
|
|
const UpdateCandidate candidate = resolve_update(prerelease_releases_json(), UpdateChannel::PreRelease, "",
|
|
"", "2.6.0", InstallFlavour::WindowsInstaller, "x86_64");
|
|
|
|
CHECK_FALSE(candidate.available);
|
|
CHECK(candidate.reason == "up_to_date");
|
|
CHECK(candidate.version == "2.6.0");
|
|
}
|
|
|
|
TEST_CASE("A beta is offered the final release of its version", "[UpdateChannel]")
|
|
{
|
|
const UpdateCandidate candidate = resolve_update(prerelease_releases_json(), UpdateChannel::PreRelease, "",
|
|
"", "2.6.0-beta", InstallFlavour::WindowsInstaller, "x86_64");
|
|
|
|
CHECK(candidate.available);
|
|
CHECK(candidate.version == "2.6.0");
|
|
}
|
|
|
|
TEST_CASE("A dev build is offered the final release of its own version", "[UpdateChannel]")
|
|
{
|
|
// Semver ranks the final release above the -dev build of the same version.
|
|
const UpdateCandidate candidate = resolve_update(prerelease_releases_json(), UpdateChannel::PreRelease, "",
|
|
"", "2.6.0-dev", InstallFlavour::WindowsInstaller, "x86_64");
|
|
|
|
CHECK(candidate.available);
|
|
CHECK(candidate.version == "2.6.0");
|
|
}
|
|
|
|
TEST_CASE("Switching to pre-release does not offer a prerelease older than the running build", "[UpdateChannel]")
|
|
{
|
|
const UpdateCandidate candidate = resolve_update(prerelease_releases_json(), UpdateChannel::PreRelease,
|
|
"sha256:2600", "stable", "2.6.0",
|
|
InstallFlavour::WindowsInstaller, "x86_64");
|
|
|
|
CHECK_FALSE(candidate.available);
|
|
CHECK(candidate.reason == "up_to_date");
|
|
}
|
|
|
|
TEST_CASE("Switching to pre-release offers a prerelease newer than the running build", "[UpdateChannel]")
|
|
{
|
|
const UpdateCandidate candidate = resolve_update(newer_prerelease_release_json(), UpdateChannel::PreRelease,
|
|
"sha256:2600", "stable", "2.6.0",
|
|
InstallFlavour::WindowsInstaller, "x86_64");
|
|
|
|
CHECK(candidate.available);
|
|
CHECK(candidate.version == "2.7.0-alpha");
|
|
}
|
|
|
|
TEST_CASE("A skipped pre-release stays skipped until a newer one appears", "[UpdateChannel]")
|
|
{
|
|
const UpdateCandidate candidate = resolve_update(newer_prerelease_release_json(), UpdateChannel::PreRelease, "",
|
|
"", "2.6.0", InstallFlavour::WindowsInstaller, "x86_64");
|
|
REQUIRE(candidate.available);
|
|
|
|
CHECK(update_is_skipped(candidate, "2.7.0-alpha"));
|
|
CHECK(update_is_skipped(candidate, "2.7.0"));
|
|
CHECK_FALSE(update_is_skipped(candidate, "2.6.0"));
|
|
|
|
std::string skip_version = "2.6.0";
|
|
update_skip_values(candidate, skip_version);
|
|
CHECK(skip_version == "2.7.0-alpha");
|
|
}
|
|
|
|
TEST_CASE("An asset version matches regardless of case", "[UpdateChannel]")
|
|
{
|
|
const UpdateCandidate candidate = resolve_update(mixed_case_asset_release_json(), UpdateChannel::PreRelease, "",
|
|
"", "2.3.1", InstallFlavour::WindowsInstaller, "x86_64");
|
|
|
|
CHECK(candidate.available);
|
|
CHECK(candidate.version == "2.3.2-rc");
|
|
CHECK(candidate.asset.name == "OrcaSlicer_Windows_Installer_V2.3.2-RC_x64.exe");
|
|
}
|
|
|
|
TEST_CASE("A release asset without a digest is offered but cannot be installed in-app", "[UpdateChannel]")
|
|
{
|
|
const UpdateCandidate candidate = resolve_update(stable_release_without_digest_json(), UpdateChannel::Stable,
|
|
"", "", "2.4.9", InstallFlavour::WindowsInstaller,
|
|
"x86_64");
|
|
|
|
CHECK(candidate.available);
|
|
CHECK(candidate.reason == "no_digest");
|
|
CHECK(candidate.asset.name == "OrcaSlicer_Windows_Installer_V2.5.0_x64.exe");
|
|
CHECK_FALSE(can_install_in_app(candidate, InstallFlavour::WindowsInstaller));
|
|
}
|
|
|
|
TEST_CASE("A supported flavour with no matching asset is offered so the release page can open", "[UpdateChannel]")
|
|
{
|
|
// A macOS bundle has nothing to download from a release that only ships a Windows
|
|
// installer, so the caller falls back to the release page.
|
|
const UpdateCandidate candidate = resolve_update(stable_releases_json(), UpdateChannel::Stable, "", "",
|
|
"2.4.9", InstallFlavour::MacOSBundle, "x86_64");
|
|
|
|
CHECK(candidate.available);
|
|
CHECK(candidate.reason == "no_asset_for_platform");
|
|
CHECK(candidate.asset.name.empty());
|
|
CHECK(candidate.version == "2.5.0");
|
|
CHECK(candidate.release_url == "https://example.invalid/releases/v2.5.0");
|
|
CHECK_FALSE(can_install_in_app(candidate, InstallFlavour::MacOSBundle));
|
|
}
|
|
|
|
TEST_CASE("Only a candidate with an asset, URL, digest and size is installed in-app", "[UpdateChannel]")
|
|
{
|
|
const UpdateCandidate candidate = resolve_update(stable_releases_json(), UpdateChannel::Stable, "", "",
|
|
"2.4.9", InstallFlavour::WindowsInstaller, "x86_64");
|
|
|
|
CHECK(can_install_in_app(candidate, InstallFlavour::WindowsInstaller));
|
|
CHECK_FALSE(can_install_in_app(candidate, InstallFlavour::Msix));
|
|
}
|
|
|
|
TEST_CASE("An asset without a size is not installed in-app", "[UpdateChannel]")
|
|
{
|
|
// prepare_download_dir can never call a zero-sized download complete, so it would be
|
|
// fetched again on every start and the quit-time install would never run.
|
|
UpdateCandidate candidate;
|
|
candidate.asset.name = "OrcaSlicer_Windows_Installer_V2.5.0_x64.exe";
|
|
candidate.asset.url = "https://example.invalid/OrcaSlicer_Windows_Installer_V2.5.0_x64.exe";
|
|
candidate.asset.digest = "sha256:2222";
|
|
candidate.asset.size = 0;
|
|
|
|
CHECK_FALSE(can_install_in_app(candidate, InstallFlavour::WindowsInstaller));
|
|
|
|
candidate.asset.size = 200;
|
|
CHECK(can_install_in_app(candidate, InstallFlavour::WindowsInstaller));
|
|
}
|
|
|
|
TEST_CASE("A portable Windows build is offered the portable zip directly", "[UpdateChannel]")
|
|
{
|
|
const UpdateCandidate candidate = resolve_update(stable_portable_release_json(), UpdateChannel::Stable, "", "",
|
|
"2.4.9", InstallFlavour::WindowsPortable, "x86_64");
|
|
|
|
CHECK(candidate.available);
|
|
CHECK(candidate.reason.empty());
|
|
CHECK(candidate.asset.name == "OrcaSlicer_Windows_portable_V2.5.0_x64.zip");
|
|
CHECK(candidate.asset.url == "https://example.invalid/OrcaSlicer_Windows_portable_V2.5.0_x64.zip");
|
|
CHECK(candidate.asset.digest == "sha256:2222portable");
|
|
CHECK_FALSE(can_install_in_app(candidate, InstallFlavour::WindowsPortable));
|
|
CHECK(is_download_only(InstallFlavour::WindowsPortable));
|
|
}
|
|
|
|
TEST_CASE("The Store offers only the stable channel", "[UpdateChannel]")
|
|
{
|
|
const UpdateCandidate prerelease = resolve_update(prerelease_releases_json(), UpdateChannel::PreRelease, "",
|
|
"", "2.5.0", InstallFlavour::Msix, "x86_64");
|
|
|
|
CHECK_FALSE(prerelease.available);
|
|
CHECK(prerelease.reason == "store_channel");
|
|
}
|
|
|
|
TEST_CASE("An AppImage update takes the main build over a discontinued _belt build", "[UpdateChannel]")
|
|
{
|
|
// The _belt asset is listed first in the release.
|
|
const UpdateCandidate candidate = resolve_update(belt_first_releases_json(), UpdateChannel::Stable, "", "",
|
|
"2.4.9", InstallFlavour::LinuxAppImage, "x86_64");
|
|
|
|
CHECK(candidate.available);
|
|
CHECK(candidate.asset.name == "OrcaSlicer_Linux_AppImage_Ubuntu2404_V2.5.0.AppImage");
|
|
CHECK(candidate.asset.digest == "sha256:2500");
|
|
CHECK_FALSE(can_install_in_app(candidate, InstallFlavour::LinuxAppImage));
|
|
CHECK(is_download_only(InstallFlavour::LinuxAppImage));
|
|
}
|
|
|
|
TEST_CASE("A _belt AppImage alone leaves the release offered without an asset", "[UpdateChannel]")
|
|
{
|
|
const UpdateCandidate candidate = resolve_update(belt_only_releases_json(), UpdateChannel::Stable, "", "",
|
|
"2.4.9", InstallFlavour::LinuxAppImage, "x86_64");
|
|
|
|
CHECK(candidate.available);
|
|
CHECK(candidate.reason == "no_asset_for_platform");
|
|
CHECK(candidate.asset.name.empty());
|
|
}
|
|
|
|
TEST_CASE("A Store flavour with no matching asset is offered so the Store or release page can open", "[UpdateChannel]")
|
|
{
|
|
const UpdateCandidate candidate = resolve_update(stable_releases_json(), UpdateChannel::Stable, "", "",
|
|
"2.4.9", InstallFlavour::Msix, "x86_64");
|
|
|
|
CHECK(candidate.available);
|
|
CHECK(candidate.reason == "no_asset_for_platform");
|
|
CHECK(candidate.asset.name.empty());
|
|
CHECK(candidate.version == "2.5.0");
|
|
CHECK(candidate.release_url == "https://example.invalid/releases/v2.5.0");
|
|
CHECK(candidate.release_notes == "newer release");
|
|
}
|
|
|
|
TEST_CASE("A stable release that is not newer is not offered even with a stale installed digest", "[UpdateChannel]")
|
|
{
|
|
const UpdateCandidate candidate = resolve_update(stable_releases_json(), UpdateChannel::Stable,
|
|
"sha256:9999", "stable", "2.5.0",
|
|
InstallFlavour::WindowsInstaller, "x86_64");
|
|
|
|
CHECK_FALSE(candidate.available);
|
|
CHECK(candidate.reason == "up_to_date");
|
|
CHECK(candidate.version == "2.5.0");
|
|
}
|
|
|
|
TEST_CASE("A recorded digest of a newer build does not hide it after a downgrade", "[UpdateChannel]")
|
|
{
|
|
// An in-app install of 2.5.0 recorded its digest, then a 2.4.0 build was run from the same
|
|
// path. The digest names the installed artifact, not proof that the running build is it.
|
|
const UpdateCandidate candidate = resolve_update(stable_releases_json(), UpdateChannel::Stable,
|
|
"sha256:2222", "stable", "2.4.0",
|
|
InstallFlavour::WindowsInstaller, "x86_64");
|
|
|
|
CHECK(candidate.available);
|
|
CHECK(candidate.version == "2.5.0");
|
|
}
|
|
|
|
TEST_CASE("A release that is not newer is not offered when its flavour has no asset either", "[UpdateChannel]")
|
|
{
|
|
const UpdateCandidate candidate = resolve_update(stable_releases_json(), UpdateChannel::Stable, "", "",
|
|
"2.5.0", InstallFlavour::Msix, "x86_64");
|
|
|
|
CHECK_FALSE(candidate.available);
|
|
}
|
|
|
|
TEST_CASE("A skipped stable version stays skipped until a newer one appears", "[UpdateChannel]")
|
|
{
|
|
const UpdateCandidate candidate = resolve_update(stable_releases_json(), UpdateChannel::Stable, "", "",
|
|
"2.4.9", InstallFlavour::WindowsInstaller, "x86_64");
|
|
|
|
CHECK(update_is_skipped(candidate, "2.5.0"));
|
|
CHECK_FALSE(update_is_skipped(candidate, "2.4.0"));
|
|
CHECK_FALSE(update_is_skipped(candidate, ""));
|
|
}
|
|
|
|
TEST_CASE("Skipping records the version", "[UpdateChannel]")
|
|
{
|
|
const UpdateCandidate stable = resolve_update(stable_releases_json(), UpdateChannel::Stable, "", "",
|
|
"2.4.9", InstallFlavour::WindowsInstaller, "x86_64");
|
|
std::string skip_version;
|
|
update_skip_values(stable, skip_version);
|
|
CHECK(skip_version == "2.5.0");
|
|
}
|
|
|
|
TEST_CASE("Channel and flavour keys round-trip through their strings", "[UpdateChannel]")
|
|
{
|
|
CHECK(update_channel_key(UpdateChannel::Stable) == "stable");
|
|
CHECK(update_channel_key(UpdateChannel::PreRelease) == "prerelease");
|
|
CHECK(update_channel_from_key("prerelease") == UpdateChannel::PreRelease);
|
|
CHECK(update_channel_from_key("stable") == UpdateChannel::Stable);
|
|
CHECK(update_channel_from_key("") == UpdateChannel::Stable);
|
|
CHECK(update_channel_from_key("unknown") == UpdateChannel::Stable);
|
|
|
|
CHECK(install_flavour_key(InstallFlavour::WindowsInstaller) == "windows_installer");
|
|
CHECK(install_flavour_key(InstallFlavour::WindowsPortable) == "windows_portable");
|
|
CHECK(install_flavour_key(InstallFlavour::MacOSBundle) == "macos_bundle");
|
|
CHECK(install_flavour_key(InstallFlavour::LinuxAppImage) == "linux_appimage");
|
|
CHECK(install_flavour_key(InstallFlavour::Msix) == "msix");
|
|
CHECK(install_flavour_key(InstallFlavour::Flatpak) == "flatpak");
|
|
CHECK(install_flavour_key(InstallFlavour::Other) == "other");
|
|
|
|
CHECK(in_app_install_supported(InstallFlavour::WindowsInstaller));
|
|
CHECK(in_app_install_supported(InstallFlavour::MacOSBundle));
|
|
CHECK_FALSE(in_app_install_supported(InstallFlavour::WindowsPortable));
|
|
CHECK_FALSE(in_app_install_supported(InstallFlavour::LinuxAppImage));
|
|
CHECK_FALSE(in_app_install_supported(InstallFlavour::Msix));
|
|
CHECK_FALSE(in_app_install_supported(InstallFlavour::Flatpak));
|
|
CHECK_FALSE(in_app_install_supported(InstallFlavour::Other));
|
|
}
|
|
|
|
TEST_CASE("Only the portable and AppImage flavours are download-only", "[UpdateChannel]")
|
|
{
|
|
CHECK(is_download_only(InstallFlavour::WindowsPortable));
|
|
CHECK(is_download_only(InstallFlavour::LinuxAppImage));
|
|
CHECK_FALSE(is_download_only(InstallFlavour::WindowsInstaller));
|
|
CHECK_FALSE(is_download_only(InstallFlavour::MacOSBundle));
|
|
CHECK_FALSE(is_download_only(InstallFlavour::Msix));
|
|
CHECK_FALSE(is_download_only(InstallFlavour::Flatpak));
|
|
CHECK_FALSE(is_download_only(InstallFlavour::Other));
|
|
}
|
|
|
|
TEST_CASE("A check with nothing to offer has nothing to do", "[UpdateChannel]")
|
|
{
|
|
UpdateRequest request;
|
|
request.available = false;
|
|
|
|
CHECK(update_action(request) == UpdateAction::None);
|
|
|
|
// Unavailable wins over every other field, a manual check included.
|
|
request.user_initiated = true;
|
|
request.download_ready = true;
|
|
CHECK(update_action(request) == UpdateAction::None);
|
|
}
|
|
|
|
TEST_CASE("An automatic check ignores a skipped update", "[UpdateChannel]")
|
|
{
|
|
UpdateRequest request;
|
|
request.available = true;
|
|
request.skipped = true;
|
|
|
|
CHECK(update_action(request) == UpdateAction::None);
|
|
|
|
// A skipped build is not reported either, even when its artifact is already verified.
|
|
request.download_ready = true;
|
|
CHECK(update_action(request) == UpdateAction::None);
|
|
}
|
|
|
|
TEST_CASE("A manual check still offers a skipped update", "[UpdateChannel]")
|
|
{
|
|
UpdateRequest request;
|
|
request.available = true;
|
|
request.skipped = true;
|
|
request.user_initiated = true;
|
|
|
|
CHECK(update_action(request) == UpdateAction::Prefetch);
|
|
|
|
// The verified artifact opens the dialog at once rather than being fetched again.
|
|
request.download_ready = true;
|
|
CHECK(update_action(request) == UpdateAction::NotifyReady);
|
|
}
|
|
|
|
TEST_CASE("A verified download is reported ready instead of prefetched", "[UpdateChannel]")
|
|
{
|
|
const UpdateRequest request{true, false, false, true};
|
|
|
|
CHECK(update_action(request) == UpdateAction::NotifyReady);
|
|
}
|
|
|
|
TEST_CASE("An available update without a verified download is prefetched", "[UpdateChannel]")
|
|
{
|
|
const UpdateRequest request{true, false, false, false};
|
|
|
|
CHECK(update_action(request) == UpdateAction::Prefetch);
|
|
}
|
|
|
|
TEST_CASE("Only pre-release entries ask Sparkle for a channel", "[UpdateChannel]")
|
|
{
|
|
// Stable is the default channel of its feed.
|
|
CHECK(sparkle_channel_key(UpdateChannel::Stable).empty());
|
|
CHECK(sparkle_channel_key(UpdateChannel::PreRelease) == "prerelease");
|
|
}
|