Skip to content

Commit

Permalink
fix Tests
Browse files Browse the repository at this point in the history
Signed-off-by: Marino Faggiana <[email protected]>
  • Loading branch information
marinofaggiana committed Oct 22, 2024
1 parent d99c1e7 commit b99cdba
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Tests/NextcloudIntegrationTests/FilesIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,24 @@ final class FilesIntegrationTests: BaseIntegrationXCTestCase {
let folderName = "TestFolder\(randomInt)"
let serverUrl = "\(TestConstants.server)/remote.php/dav/files/\(TestConstants.username)"
let serverUrlFileName = "\(serverUrl)/\(folderName)"
let domain = NCDomain.Domain(account: TestConstants.account, urlBase: TestConstants.server, user: TestConstants.username, userId: TestConstants.username, sceneIdentifier: "")

NCSession.shared.appendSession(account: TestConstants.account, urlBase: TestConstants.server, user: TestConstants.username, userId: TestConstants.username)
let session = NCSession.shared.getSession(account: TestConstants.account)

NextcloudKit.shared.setup(delegate: NCNetworking.shared)
NextcloudKit.shared.appendAccount(TestConstants.account, urlBase: TestConstants.server, user: TestConstants.username, userId: TestConstants.username, password: appToken, userAgent: userAgent, nextcloudVersion: 0, groupIdentifier: NCBrandOptions.shared.capabilitiesGroup)
NextcloudKit.shared.appendSession(account: TestConstants.account, urlBase: TestConstants.server, user: TestConstants.username, userId: TestConstants.username, password: appToken, userAgent: userAgent, nextcloudVersion: 0, groupIdentifier: NCBrandOptions.shared.capabilitiesGroup)

// Test creating folder
NCNetworking.shared.createFolder(fileName: folderName, serverUrl: serverUrl, overwrite: true, withPush: true, sceneIdentifier: nil, domain: domain) { error in
NCNetworking.shared.createFolder(fileName: folderName, serverUrl: serverUrl, overwrite: true, withPush: true, metadata: nil, sceneIdentifier: nil, session: session ) { error in

XCTAssertEqual(NKError.success.errorCode, error.errorCode)
XCTAssertEqual(NKError.success.errorDescription, error.errorDescription)

Thread.sleep(forTimeInterval: 1)

// Test reading folder, should exist
NCNetworking.shared.readFolder(serverUrl: serverUrlFileName, account: TestConstants.username) { account, metadataFolder, _, _, _, _ in
NCNetworking.shared.readFolder(serverUrl: serverUrlFileName, account: TestConstants.username, checkResponseDataChanged: false, queue: .main) { account, metadataFolder, _, _, _ in

XCTAssertEqual(TestConstants.account, account)
XCTAssertEqual(NKError.success.errorCode, error.errorCode)
XCTAssertEqual(NKError.success.errorDescription, error.errorDescription)
Expand All @@ -63,15 +66,15 @@ final class FilesIntegrationTests: BaseIntegrationXCTestCase {

Task {
// Test deleting folder
await _ = NCNetworking.shared.deleteMetadata(metadataFolder!)
await _ = NCNetworking.shared.deleteFileOrFolder(serverUrlFileName: serverUrlFileName, account: TestConstants.account)

XCTAssertEqual(NKError.success.errorCode, error.errorCode)
XCTAssertEqual(NKError.success.errorDescription, error.errorDescription)

try await Task.sleep(for: .seconds(1))

// Test reading folder, should NOT exist
NCNetworking.shared.readFolder(serverUrl: serverUrlFileName, account: TestConstants.username) { account, metadataFolder, _, _, _, _ in
NCNetworking.shared.readFolder(serverUrl: serverUrlFileName, account: TestConstants.username, checkResponseDataChanged: false, queue: .main) { account, metadataFolder, _, _, _ in

defer { expectation.fulfill() }

Expand Down

0 comments on commit b99cdba

Please sign in to comment.