* Added init with template test. Supports #99 * Moved expectedTemplateSource outside of test function. Supports #99 Co-authored-by: thecb4 <cavelle@tehcb4.io>
This commit is contained in:
parent
2385b04252
commit
45850d66e0
|
@ -73,4 +73,85 @@ final class InitCommandTests: XCTestCase {
|
|||
// finally, clean up
|
||||
try packageDirectory.delete()
|
||||
}
|
||||
|
||||
func testInitWithTokamakTemplate() throws {
|
||||
// given I've created a directory
|
||||
let package = "fusion"
|
||||
let packageDirectory = testFixturesDirectory.appending(component: package)
|
||||
|
||||
// it's ok if there is nothing to delete
|
||||
do { try packageDirectory.delete() } catch {}
|
||||
|
||||
try packageDirectory.mkdir()
|
||||
|
||||
XCTAssertTrue(packageDirectory.exists, "Did not create \(package) directory")
|
||||
|
||||
AssertExecuteCommand(
|
||||
command: "carton init --template tokamak",
|
||||
cwd: packageDirectory.url
|
||||
)
|
||||
|
||||
// Confirm that the files are actually in the folder
|
||||
XCTAssertTrue(packageDirectory.ls().contains("Package.swift"), "Package.swift does not exist")
|
||||
XCTAssertTrue(packageDirectory.ls().contains("README.md"), "README.md does not exist")
|
||||
XCTAssertTrue(packageDirectory.ls().contains(".gitignore"), ".gitignore does not exist")
|
||||
XCTAssertTrue(packageDirectory.ls().contains("Sources"), "Sources does not exist")
|
||||
XCTAssertTrue(
|
||||
packageDirectory.ls().contains("Sources/\(package)"),
|
||||
"Sources/\(package) does not exist"
|
||||
)
|
||||
XCTAssertTrue(
|
||||
packageDirectory.ls().contains("Sources/\(package)/main.swift"),
|
||||
"Sources/\(package)/main.swift does not exist"
|
||||
)
|
||||
XCTAssertTrue(packageDirectory.ls().contains("Tests"), "Tests does not exist")
|
||||
XCTAssertTrue(
|
||||
packageDirectory.ls().contains("Tests/LinuxMain.swift"),
|
||||
"Tests/LinuxMain.swift does not exist"
|
||||
)
|
||||
XCTAssertTrue(
|
||||
packageDirectory.ls().contains("Tests/\(package)Tests"),
|
||||
"Tests/\(package)Tests does not exist"
|
||||
)
|
||||
XCTAssertTrue(
|
||||
packageDirectory.ls().contains("Tests/\(package)Tests/\(package)Tests.swift"),
|
||||
"Tests/\(package)Tests/\(package)Tests.swift does not exist"
|
||||
)
|
||||
XCTAssertTrue(
|
||||
packageDirectory.ls().contains("Tests/\(package)Tests/XCTestManifests.swift"),
|
||||
"Tests/\(package)Tests/XCTestManifests.swift does not exist"
|
||||
)
|
||||
|
||||
let actualTemplateSource = try String(contentsOfFile: packageDirectory
|
||||
.appending(components: "Sources", package, "main.swift").pathString)
|
||||
|
||||
XCTAssertEqual(expectedTemplateSource, actualTemplateSource, "Template Sources do not match")
|
||||
|
||||
// finally, clean up
|
||||
try packageDirectory.delete()
|
||||
}
|
||||
|
||||
let expectedTemplateSource =
|
||||
"""
|
||||
import TokamakDOM
|
||||
|
||||
struct TokamakApp: App {
|
||||
var body: some Scene {
|
||||
WindowGroup("Tokamak App") {
|
||||
ContentView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ContentView: View {
|
||||
var body: some View {
|
||||
Text("Hello, world!")
|
||||
}
|
||||
}
|
||||
|
||||
// @main attribute is not supported in SwiftPM apps.
|
||||
// See https://bugs.swift.org/browse/SR-12683 for more details.
|
||||
TokamakApp.main()
|
||||
|
||||
"""
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue