FilesIntegrationTests.swift 4.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // NextcloudIntegrationTests.swift
  3. // NextcloudIntegrationTests
  4. //
  5. // Created by Milen Pivchev on 5/19/23.
  6. // Copyright © 2023 Marino Faggiana. All rights reserved.
  7. //
  8. // This program is free software: you can redistribute it and/or modify
  9. // it under the terms of the GNU General Public License as published by
  10. // the Free Software Foundation, either version 3 of the License, or
  11. // (at your option) any later version.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU General Public License
  19. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. //
  21. import XCTest
  22. import NextcloudKit
  23. @testable import Nextcloud
  24. final class FilesIntegrationTests: BaseIntegrationXCTestCase {
  25. override func setUp() {
  26. NCAccount().deleteAllAccounts()
  27. }
  28. // func test_createReadDeleteFolder_withProperParams_shouldCreateReadDeleteFolder() throws {
  29. // let expectation = expectation(description: "Should finish last callback")
  30. //
  31. // let folderName = "TestFolder\(randomInt)"
  32. // let serverUrl = "\(TestConstants.server)/remote.php/dav/files/\(TestConstants.username)"
  33. // let serverUrlFileName = "\(serverUrl)/\(folderName)"
  34. //
  35. // NCSession.shared.appendSession(account: TestConstants.account, urlBase: TestConstants.server, user: TestConstants.username, userId: TestConstants.username)
  36. // let session = NCSession.shared.getSession(account: TestConstants.account)
  37. //
  38. // NextcloudKit.shared.setup(delegate: NCNetworking.shared)
  39. // 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)
  40. //
  41. // // Test creating folder
  42. // NCNetworking.shared.createFolder(fileName: folderName, serverUrl: serverUrl, overwrite: true, withPush: true, metadata: nil, sceneIdentifier: nil, session: session ) { error in
  43. //
  44. // XCTAssertEqual(NKError.success.errorCode, error.errorCode)
  45. // XCTAssertEqual(NKError.success.errorDescription, error.errorDescription)
  46. //
  47. // Thread.sleep(forTimeInterval: 1)
  48. //
  49. // // Test reading folder, should exist
  50. // NCNetworking.shared.readFolder(serverUrl: serverUrlFileName, account: TestConstants.username, checkResponseDataChanged: false, queue: .main) { account, metadataFolder, _, _, _ in
  51. //
  52. // XCTAssertEqual(TestConstants.account, account)
  53. // XCTAssertEqual(NKError.success.errorCode, error.errorCode)
  54. // XCTAssertEqual(NKError.success.errorDescription, error.errorDescription)
  55. // XCTAssertEqual(metadataFolder?.fileName, folderName)
  56. //
  57. // // Check Realm directory, should exist
  58. // let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "serverUrl == %@", serverUrlFileName))
  59. // XCTAssertNotNil(directory)
  60. //
  61. // Thread.sleep(forTimeInterval: 1)
  62. //
  63. // Task {
  64. // // Test deleting folder
  65. // await _ = NCNetworking.shared.deleteFileOrFolder(serverUrlFileName: serverUrlFileName, account: TestConstants.account)
  66. //
  67. // XCTAssertEqual(NKError.success.errorCode, error.errorCode)
  68. // XCTAssertEqual(NKError.success.errorDescription, error.errorDescription)
  69. //
  70. // try await Task.sleep(for: .seconds(1))
  71. //
  72. // // Test reading folder, should NOT exist
  73. // NCNetworking.shared.readFolder(serverUrl: serverUrlFileName, account: TestConstants.username, checkResponseDataChanged: false, queue: .main) { account, metadataFolder, _, _, _ in
  74. //
  75. // defer { expectation.fulfill() }
  76. //
  77. // XCTAssertEqual(0, error.errorCode)
  78. // XCTAssertNil(metadataFolder?.fileName)
  79. //
  80. // // Check Realm directory, should NOT exist
  81. // let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "serverUrl == %@", serverUrlFileName))
  82. // XCTAssertNil(directory)
  83. // }
  84. // }
  85. // }
  86. // }
  87. //
  88. // waitForExpectations(timeout: TestConstants.timeoutLong)
  89. // }
  90. }