1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-11-08 05:30:05 +01:00

♻️ Migrate more tests to Swift Testing

This commit is contained in:
2025-09-29 16:31:30 +02:00
parent 9c9720de42
commit 5b27d9f0ea
18 changed files with 330 additions and 364 deletions

View File

@@ -0,0 +1,45 @@
//
// ValetRcTest.swift
// Unit Tests
//
// Created by Nico Verbruggen on 20/01/2023.
// Copyright © 2023 Nico Verbruggen. All rights reserved.
//
import Testing
import Foundation
struct ValetRcTest {
// MARK: - Test Files
static var validPath: URL {
return TestBundle.url(forResource: "valetrc", withExtension: "valid")!
}
static var brokenPath: URL {
return TestBundle.url(forResource: "valetrc", withExtension: "broken")!
}
// MARK: - Tests
@Test func test_can_extract_fields_from_valet_rc_file() throws {
let fakeFile = RCFile.fromPath("/Users/fake/file.rc")
#expect(nil == fakeFile)
// Can parse the file
let validFile = RCFile.fromPath(ValetRcTest.validPath.path)
#expect(nil != validFile)
let fields = validFile!.fields
// Correctly parses and trims (and omits double quotes) per line
#expect(fields["PHP"] == "php@8.2")
#expect(fields["OTHER"] == "thing")
#expect(fields["PHPMON_WATCH"] == "true")
#expect(fields["SYNTAX"] == "variable")
// Ignores entries prefixed with #
#expect(!fields.keys.contains("#PHP"))
// Ignores invalid lines
#expect(!fields.keys.contains("OOF"))
}
}