Skip to content

Commit

Permalink
Use resources instead of compiler magic to access test calendar file
Browse files Browse the repository at this point in the history
  • Loading branch information
designatednerd committed Aug 29, 2022
1 parent 88fcfea commit b9563b3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
15 changes: 10 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ let package = Package(
.target(name: "PluginBinary")
]
),
.testTarget(name: "DoNilDisturbPluginTests",
dependencies: [
.target(name: "PluginBinary"),
.product(name: "iCalendar", package: "iCalendar")
])
.testTarget(
name: "DoNilDisturbPluginTests",
dependencies: [
.target(name: "PluginBinary"),
.product(name: "iCalendar", package: "iCalendar")
],
resources: [
.copy("Resources"),
]
)
]
)
6 changes: 2 additions & 4 deletions Tests/DoNilDisturbPluginTests/DoNotDisturbPluginTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ final class DoNotDisturbPluginTests: XCTestCase {

func testHolidayLoad() throws {
let date = Foundation.Calendar.current.date(from: DateComponents(year: 2022, month: 8, day: 30, hour: 13))!
let path = #filePath
let parent = (path as NSString).deletingLastPathComponent
let icalPath = parent.appending("/TestCal.ics")
let icalContents = try String(contentsOfFile: icalPath)
let calendarFileURL = try XCTUnwrap(Bundle.module.url(forResource: "TestCal", withExtension: "ics", subdirectory: "Resources"))
let icalContents = try String(contentsOf: calendarFileURL)
let parseResult = Parser.parse(ics: icalContents)
switch parseResult {
case .success(let calendar):
Expand Down
File renamed without changes.

0 comments on commit b9563b3

Please sign in to comment.