Fix sample project, cleanup tests and add github action

This commit is contained in:
Stefan Ceriu
2022-05-17 12:23:23 +03:00
parent ba2cef62b0
commit 45cb162e5a
7 changed files with 101 additions and 186 deletions
@@ -9,13 +9,40 @@ import XCTest
@testable import MatrixRustSDK
class MatrixRustSDKTests: XCTestCase {
func testExample() throws {
static var client: Client!
override class func setUp() {
client = try! guestClient(basePath: basePath, homeserver: "https://matrix.org")
}
func testClientProperties() {
XCTAssertTrue(Self.client.isGuest())
XCTAssertNotNil(try? Self.client.restoreToken())
XCTAssertNotNil(try? Self.client.deviceId())
XCTAssertNotNil(try? Self.client.displayName())
}
func testReadOnlyFileSystemError() {
do {
let _ = try loginNewClient(basePath: "", username: "test", password: "test")
} catch ClientError.generic(let message) {
} catch ClientError.Generic(let message) {
XCTAssertNotNil(message.range(of: "Read-only file system"))
} catch {
XCTFail("Not expecting any other kind of exception")
}
}
// MARK: - Private
static private var basePath: String {
guard let url = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first else {
fatalError("Should always be able to retrieve the caches directory")
}
try? FileManager.default.createDirectory(at: url, withIntermediateDirectories: false, attributes: nil)
return url.path
}
}