mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 03:50:08 +02:00
✨ Add updater to project
If you want to see the source code to the updater, you can find it here: https://github.com/nicoverbruggen/phpmon-updater Starting with version 6.0, the code of the updater will be included in this repository.
This commit is contained in:
53
tests/unit/Parsers/CaskFileParserTest.swift
Normal file
53
tests/unit/Parsers/CaskFileParserTest.swift
Normal file
@ -0,0 +1,53 @@
|
||||
//
|
||||
// CaskFileParserTest.swift
|
||||
// Unit Tests
|
||||
//
|
||||
// Created by Nico Verbruggen on 04/02/2023.
|
||||
// Copyright © 2023 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class CaskFileParserTest: XCTestCase {
|
||||
|
||||
// MARK: - Test Files
|
||||
static var exampleFilePath: URL {
|
||||
return Bundle(for: Self.self)
|
||||
.url(forResource: "phpmon-dev", withExtension: "rb")!
|
||||
}
|
||||
|
||||
func test_can_extract_fields_from_cask_file() async throws {
|
||||
guard let caskFile = await CaskFile.from(url: CaskFileParserTest.exampleFilePath) else {
|
||||
return XCTFail("The CaskFile could not be parsed, check the log for more info")
|
||||
}
|
||||
|
||||
XCTAssertEqual(
|
||||
caskFile.version,
|
||||
"5.7.2_1035"
|
||||
)
|
||||
XCTAssertEqual(
|
||||
caskFile.sha256,
|
||||
"1cb147bd1b1fbd52971d90dff577465b644aee7c878f15ede57f46e8f217067a"
|
||||
)
|
||||
XCTAssertEqual(
|
||||
caskFile.name,
|
||||
"PHP Monitor DEV"
|
||||
)
|
||||
XCTAssertEqual(
|
||||
caskFile.url,
|
||||
"https://github.com/nicoverbruggen/phpmon/releases/download/v5.7.2/phpmon-dev.zip"
|
||||
)
|
||||
}
|
||||
|
||||
func test_can_extract_fields_from_remote_cask_file() async throws {
|
||||
guard let caskFile = await CaskFile.from(url: Constants.Urls.StableBuildCaskFile) else {
|
||||
return XCTFail("The remote CaskFile could not be parsed, check the log for more info")
|
||||
}
|
||||
|
||||
XCTAssertTrue(caskFile.properties.keys.contains("version"))
|
||||
XCTAssertTrue(caskFile.properties.keys.contains("homepage"))
|
||||
XCTAssertTrue(caskFile.properties.keys.contains("url"))
|
||||
XCTAssertTrue(caskFile.properties.keys.contains("appcast"))
|
||||
}
|
||||
|
||||
}
|
14
tests/unit/Test Files/brew/phpmon-dev.rb
Normal file
14
tests/unit/Test Files/brew/phpmon-dev.rb
Normal file
@ -0,0 +1,14 @@
|
||||
cask 'phpmon-dev' do
|
||||
depends_on formula: 'gnu-sed'
|
||||
|
||||
version '5.7.2_1035'
|
||||
sha256 '1cb147bd1b1fbd52971d90dff577465b644aee7c878f15ede57f46e8f217067a'
|
||||
|
||||
url 'https://github.com/nicoverbruggen/phpmon/releases/download/v5.7.2/phpmon-dev.zip'
|
||||
appcast 'https://github.com/nicoverbruggen/phpmon/releases.atom'
|
||||
name 'PHP Monitor DEV'
|
||||
homepage 'https://phpmon.app'
|
||||
|
||||
app 'PHP Monitor DEV.app', target: "PHP Monitor DEV.app"
|
||||
end
|
||||
|
@ -1,47 +0,0 @@
|
||||
//
|
||||
// AppUpdaterCheckTest.swift
|
||||
// PHP Monitor
|
||||
//
|
||||
// Created by Nico Verbruggen on 10/05/2022.
|
||||
// Copyright © 2023 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class AppUpdaterCheckTest: XCTestCase {
|
||||
|
||||
func test_can_retrieve_version_from_cask() async {
|
||||
let caskVersion = await AppUpdateChecker.retrieveVersionFromCask()
|
||||
|
||||
let version = VersionExtractor.from(caskVersion)
|
||||
|
||||
XCTAssertNotNil(version)
|
||||
}
|
||||
|
||||
func test_tagged_release_omits_zero_patch() {
|
||||
let version = AppVersion.from("3.5.0_333")!
|
||||
|
||||
XCTAssertEqual(version.tagged, "3.5")
|
||||
XCTAssertEqual(version.version, "3.5.0")
|
||||
}
|
||||
|
||||
func test_tagged_release_doesnt_omit_non_zero_patch() {
|
||||
let version = AppVersion.from("3.5.1_333")!
|
||||
|
||||
XCTAssertEqual(version.tagged, "3.5.1")
|
||||
XCTAssertEqual(version.version, "3.5.1")
|
||||
}
|
||||
|
||||
func test_tag_truncation_does_not_affect_major_versions() {
|
||||
var version = AppVersion.from("5.0_333")!
|
||||
|
||||
XCTAssertEqual(version.tagged, "5.0")
|
||||
XCTAssertEqual(version.version, "5.0")
|
||||
|
||||
version = AppVersion.from("5.0.0_333")!
|
||||
|
||||
XCTAssertEqual(version.tagged, "5.0")
|
||||
XCTAssertEqual(version.version, "5.0.0")
|
||||
}
|
||||
|
||||
}
|
@ -28,7 +28,7 @@ class AppVersionTest: XCTestCase {
|
||||
|
||||
XCTAssertNotNil(version)
|
||||
XCTAssertEqual("1.0.0", version?.version)
|
||||
XCTAssertEqual("600", version?.build)
|
||||
XCTAssertEqual(600, version?.build)
|
||||
XCTAssertEqual(nil, version?.suffix)
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ class AppVersionTest: XCTestCase {
|
||||
|
||||
XCTAssertNotNil(version)
|
||||
XCTAssertEqual("1.0.0", version?.version)
|
||||
XCTAssertEqual("870", version?.build)
|
||||
XCTAssertEqual(870, version?.build)
|
||||
XCTAssertEqual("dev", version?.suffix)
|
||||
}
|
||||
|
||||
@ -55,8 +55,48 @@ class AppVersionTest: XCTestCase {
|
||||
|
||||
XCTAssertNotNil(version)
|
||||
XCTAssertEqual("1.0.0", version?.version)
|
||||
XCTAssertEqual("870", version?.build)
|
||||
XCTAssertEqual(870, version?.build)
|
||||
XCTAssertEqual("dev", version?.suffix)
|
||||
}
|
||||
|
||||
func test_tagged_release_omits_zero_patch() {
|
||||
let version = AppVersion.from("3.5.0_333")!
|
||||
|
||||
XCTAssertEqual(version.tagged, "3.5")
|
||||
XCTAssertEqual(version.version, "3.5.0")
|
||||
}
|
||||
|
||||
func test_tagged_release_doesnt_omit_non_zero_patch() {
|
||||
let version = AppVersion.from("3.5.1_333")!
|
||||
|
||||
XCTAssertEqual(version.tagged, "3.5.1")
|
||||
XCTAssertEqual(version.version, "3.5.1")
|
||||
}
|
||||
|
||||
func test_tag_truncation_does_not_affect_major_versions() {
|
||||
var version = AppVersion.from("5.0_333")!
|
||||
|
||||
XCTAssertEqual(version.tagged, "5.0")
|
||||
XCTAssertEqual(version.version, "5.0")
|
||||
|
||||
version = AppVersion.from("5.0.0_333")!
|
||||
|
||||
XCTAssertEqual(version.tagged, "5.0")
|
||||
XCTAssertEqual(version.version, "5.0.0")
|
||||
}
|
||||
|
||||
func test_can_compare_version_numbers() {
|
||||
// Build is newer
|
||||
XCTAssertTrue(AppVersion.from("5.0_101")! > AppVersion.from("5.0_100")!)
|
||||
|
||||
// Version and build is the same
|
||||
XCTAssertFalse(AppVersion.from("5.0.0_100")! > AppVersion.from("5.0_100")!)
|
||||
|
||||
// Version is newer
|
||||
XCTAssertTrue(AppVersion.from("5.1_100")! > AppVersion.from("5.0_100")!)
|
||||
|
||||
// Build is older
|
||||
XCTAssertFalse(AppVersion.from("5.0_101")! > AppVersion.from("5.0_102")!)
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user