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:
45
tests/unit/_ST/Parsers/ValetRcTest.swift
Normal file
45
tests/unit/_ST/Parsers/ValetRcTest.swift
Normal 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"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user