mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 03:50:08 +02:00
✨ Correctly parse .valetrc files
This commit is contained in:
@ -12,19 +12,39 @@ class ValetRcTest: XCTestCase {
|
||||
|
||||
// MARK: - Test Files
|
||||
|
||||
static var path: URL {
|
||||
static var validPath: URL {
|
||||
return Bundle(for: Self.self)
|
||||
.url(forResource: "valetrc", withExtension: "rc")!
|
||||
.url(forResource: "valetrc", withExtension: "valid")!
|
||||
}
|
||||
|
||||
static var brokenPath: URL {
|
||||
return Bundle(for: Self.self)
|
||||
.url(forResource: "valetrc", withExtension: "broken")!
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Tests
|
||||
|
||||
func test_can_extract_fields_from_valetrc_file() throws {
|
||||
// TODO: Load the path and get the fields
|
||||
}
|
||||
let fakeFile = RCFile.fromPath("/Users/fake/file.rc")
|
||||
XCTAssertNil(fakeFile)
|
||||
|
||||
func test_skip_invalid_fields_valetrc_file() throws {
|
||||
// TODO: Load the path and throw error
|
||||
}
|
||||
// Can parse the file
|
||||
let validFile = RCFile.fromPath(ValetRcTest.validPath.path)
|
||||
XCTAssertNotNil(validFile)
|
||||
|
||||
let fields = validFile!.fields
|
||||
|
||||
// Correctly parses and trims (and omits double quotes) per line
|
||||
XCTAssertEqual(fields["PHP"], "php@8.2")
|
||||
XCTAssertEqual(fields["OTHER"], "thing")
|
||||
XCTAssertEqual(fields["PHPMON_WATCH"], "true")
|
||||
XCTAssertEqual(fields["SYNTAX"], "variable")
|
||||
|
||||
// Ignores entries prefixed with #
|
||||
XCTAssertTrue(!fields.keys.contains("#PHP"))
|
||||
|
||||
// Ignores invalid lines
|
||||
XCTAssertTrue(!fields.keys.contains("OOF"))
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +0,0 @@
|
||||
PHP=php@8.2
|
||||
OTHER=thing
|
||||
PHPMON_WATCH=true
|
6
tests/unit/Test Files/valet/valetrc.valid
Normal file
6
tests/unit/Test Files/valet/valetrc.valid
Normal file
@ -0,0 +1,6 @@
|
||||
PHP=php@8.2
|
||||
#PHP=php
|
||||
OTHER=thing
|
||||
PHPMON_WATCH=true
|
||||
SYNTAX = "variable"
|
||||
OOF:NICE
|
Reference in New Issue
Block a user