Skip to content

Commit

Permalink
fix: linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bouassaba committed Nov 24, 2024
1 parent 0a7adab commit d70109b
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 69 deletions.
8 changes: 4 additions & 4 deletions Sources/Common/Error.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public struct VOErrorResponse: Decodable, Error {
}

public enum Code: String, Codable, CaseIterable {
/* API */
// API
case groupNotFound = "group_not_found"
case fileNotFound = "file_not_found"
case invalidPath = "invalid_path"
Expand Down Expand Up @@ -71,7 +71,7 @@ public struct VOErrorResponse: Decodable, Error {
case invalidApiKey = "invalid_api_key"
case pathVariablesAndBodyParametersNotConsistent = "path_variables_and_body_parameters_not_consistent"

/* IdP */
// IdP
case usernameUnavailable = "username_unavailable"
case resourceNotFound = "resource_not_found"
case invalidUsernameOrPassword = "invalid_username_or_password"
Expand All @@ -84,11 +84,11 @@ public struct VOErrorResponse: Decodable, Error {
case unsupportedGrantType = "unsupported_grant_type"
case passwordValidationFailed = "password_validation_failed"

/* Common */
// Common
case internalServerError = "internal_server_error"
case requestValidationError = "request_validation_error"

/* Unexpected */
// Unexpected
case unknown

public init(rawValue: String) {
Expand Down
48 changes: 24 additions & 24 deletions Tests/FileTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class FileTests: XCTestCase {
storageCapacity: 100_000_000
))

/* Create files */
// Create files
var options: [VOFile.CreateFileOptions] = []
for index in 0..<6 {
options.append(
Expand All @@ -42,45 +42,45 @@ final class FileTests: XCTestCase {
try await files.append(factory.file(options[index]))
}

/* Test creation */
// Test creation
for index in 0..<files.count {
XCTAssertEqual(files[index].name, options[index].name)
XCTAssertEqual(files[index].workspaceID, options[index].workspaceID)
XCTAssertEqual(files[index].permission, .owner)
}

/* Test list */
// Test list

/* Page 1 */
// Page 1
let page1 = try await client.fetchList(workspace.rootID, options: .init(page: 1, size: 3))
XCTAssertGreaterThanOrEqual(page1.totalElements, options.count)
XCTAssertEqual(page1.totalPages, 2)
XCTAssertEqual(page1.page, 1)
XCTAssertEqual(page1.size, 3)
XCTAssertEqual(page1.data.count, page1.size)

/* Page 2 */
// Page 2
let page2 = try await client.fetchList(workspace.rootID, options: .init(page: 2, size: 3))
XCTAssertGreaterThanOrEqual(page2.totalElements, options.count)
XCTAssertEqual(page2.page, 2)
XCTAssertEqual(page2.size, 3)
XCTAssertEqual(page2.data.count, page2.size)

/* Test fetch */
// Test fetch
let file = try await client.fetch(files[0].id)
XCTAssertEqual(file.name, files[0].name)
XCTAssertEqual(file.workspaceID, files[0].workspaceID)
XCTAssertEqual(file.permission, .owner)
XCTAssertEqual(file.snapshot!.original.size!, options[0].data.count)

/* Test patch name */
// Test patch name
let newName = "New File.txt"
let resultAlpha = try await client.patchName(file.id, options: .init(name: newName))
XCTAssertEqual(resultAlpha.name, newName)
let fileAlpha = try await client.fetch(file.id)
XCTAssertEqual(fileAlpha.name, newName)

/* Test delete */
// Test delete
for file in files {
try await client.delete(file.id)
}
Expand Down Expand Up @@ -121,7 +121,7 @@ final class FileTests: XCTestCase {
))
let folder = try await factory.folder(.init(workspaceID: workspace.id, name: "Test Folder"))

/* Send invitation and accept it */
// Send invitation and accept it
let otherUser = try await otherFactory.client.identityUser.fetch()
let invitations = try await factory.client.invitation.create(
.init(
Expand All @@ -130,28 +130,28 @@ final class FileTests: XCTestCase {
))
try await otherFactory.client.invitation.accept(invitations[0].id)

/* Grant permission to the other user */
// Grant permission to the other user
try await client.grantUserPermission(.init(ids: [folder.id], userID: otherUser.id, permission: .editor))

/* Test the other user has the permission */
// Test the other user has the permission
let permissions = try await client.fetchUserPermissions(folder.id)
XCTAssertEqual(permissions.count, 1)
XCTAssertEqual(permissions.first!.user.id, otherUser.id)
XCTAssertEqual(permissions.first!.permission, .editor)

/* Test the other user can access the file */
// Test the other user can access the file
let folderAgain = try await otherClient.fetch(folder.id)
XCTAssertEqual(folderAgain.id, folder.id)
XCTAssertEqual(folderAgain.permission, .editor)

/* Revoke permission from the other user */
// Revoke permission from the other user
try await client.revokeUserPermission(.init(ids: [folder.id], userID: otherUser.id))

/* Test the other user no longer has the permission */
// Test the other user no longer has the permission
let newPermissions = try await client.fetchUserPermissions(folder.id)
XCTAssertEqual(newPermissions.count, 0)

/* Test the other user can no longer access the file */
// Test the other user can no longer access the file
do {
_ = try await otherClient.fetch(folder.id)
expectedToFail()
Expand Down Expand Up @@ -188,7 +188,7 @@ final class FileTests: XCTestCase {
let group = try await factory.group(.init(name: "Test Group", organizationID: organization.id))
let folder = try await factory.folder(.init(workspaceID: workspace.id, name: "Test Folder"))

/* Send invitation and accept it */
// Send invitation and accept it
let otherUser = try await otherFactory.client.identityUser.fetch()
let invitations = try await factory.client.invitation.create(
.init(
Expand All @@ -197,31 +197,31 @@ final class FileTests: XCTestCase {
))
try await otherFactory.client.invitation.accept(invitations[0].id)

/* Add the other user to the group */
// Add the other user to the group
try await factory.client.group.addMember(group.id, options: .init(userID: otherUser.id))

/* Grant permission to the group */
// Grant permission to the group
try await client.grantGroupPermission(.init(ids: [folder.id], groupID: group.id, permission: .editor))

/* Test the group has the permission */
// Test the group has the permission
let permissions = try await client.fetchGroupPermissions(folder.id)
XCTAssertEqual(permissions.count, 1)
XCTAssertEqual(permissions.first?.group.id, group.id)
XCTAssertEqual(permissions.first?.permission, .editor)

/* Test the other user can access the file */
// Test the other user can access the file
let folderAgain = try await otherClient.fetch(folder.id)
XCTAssertEqual(folderAgain.id, folder.id)
XCTAssertEqual(folderAgain.permission, .editor)

/* Revoke permission from the group */
// Revoke permission from the group
try await client.revokeGroupPermission(.init(ids: [folder.id], groupID: group.id))

/* Test the group no longer has the permission */
// Test the group no longer has the permission
let newPermissions = try await client.fetchGroupPermissions(folder.id)
XCTAssertEqual(newPermissions.count, 0)

/* Test the other user can no longer access the file */
// Test the other user can no longer access the file
do {
_ = try await otherClient.fetch(folder.id)
expectedToFail()
Expand Down Expand Up @@ -357,7 +357,7 @@ final class FileTests: XCTestCase {
XCTAssertEqual(copiedFile.name, file.name)
XCTAssertEqual(copiedFile.parentID, folder.id)

/* Check the copied file name has a suffix that makes it unique */
// Check the copied file name has a suffix that makes it unique
let copiedFileAgain = try await client.copy(file.id, to: workspace.rootID)
XCTAssertNotEqual(file.name, copiedFileAgain.name)
let lhs = (copiedFileAgain.name as NSString).deletingPathExtension
Expand Down
16 changes: 8 additions & 8 deletions Tests/GroupTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class GroupTests: XCTestCase {

let organization = try await factory.organization(.init(name: "Test Organization"))

/* Create groups */
// Create groups
var options: [VOGroup.CreateOptions] = []
for index in 0..<6 {
options.append(.init(name: "Test Group \(index)", organizationID: organization.id))
Expand All @@ -30,42 +30,42 @@ final class GroupTests: XCTestCase {
try await groups.append(factory.group(options[index]))
}

/* Test creation */
// Test creation
for index in 0..<groups.count {
XCTAssertEqual(groups[index].name, options[index].name)
XCTAssertEqual(groups[index].organization.id, options[index].organizationID)
}

/* Test list */
// Test list

/* Page 1 */
// Page 1
let page1 = try await client.fetchList(.init(page: 1, size: 3))
XCTAssertGreaterThanOrEqual(page1.totalElements, options.count)
XCTAssertGreaterThanOrEqual(page1.totalPages, 2)
XCTAssertEqual(page1.page, 1)
XCTAssertEqual(page1.size, 3)
XCTAssertEqual(page1.data.count, page1.size)

/* Page 2 */
// Page 2
let page2 = try await client.fetchList(.init(page: 2, size: 3))
XCTAssertGreaterThanOrEqual(page2.totalElements, options.count)
XCTAssertEqual(page2.page, 2)
XCTAssertEqual(page2.size, 3)
XCTAssertEqual(page2.data.count, page2.size)

/* Test fetch */
// Test fetch
let group = try await client.fetch(groups[0].id)
XCTAssertEqual(group.name, groups[0].name)
XCTAssertEqual(group.organization.id, groups[0].organization.id)

/* Test patch name */
// Test patch name
let newName = "New Group"
let alpha = try await client.patchName(group.id, options: .init(name: newName))
XCTAssertEqual(alpha.name, newName)
let beta = try await client.fetch(group.id)
XCTAssertEqual(beta.name, newName)

/* Test delete */
// Test delete
for group in groups {
try await client.delete(group.id)
}
Expand Down
6 changes: 3 additions & 3 deletions Tests/InsightsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ final class InsightsTests: XCTestCase {
var info = try await client.fetchInfo(file.id)
XCTAssertFalse(info.isOutdated)

/* Patch file to get a new snapshot and make the insights "outdated" */
// Patch file to get a new snapshot and make the insights "outdated"
_ = try await factory.client.file.patch(
file.id,
options: .init(data: Data(Constants.text.utf8), name: file.name)
Expand All @@ -128,11 +128,11 @@ final class InsightsTests: XCTestCase {
info = try await client.fetchInfo(file.id)
XCTAssertTrue(info.isOutdated)

/* Patch insights */
// Patch insights
task = try await client.patch(file.id)
_ = try await factory.client.task.wait(task.id)

/* Check if no longer "outdated" */
// Check if no longer "outdated"
info = try await client.fetchInfo(file.id)
XCTAssertFalse(info.isOutdated)
}
Expand Down
18 changes: 9 additions & 9 deletions Tests/OrganizationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class OrganizationTests: XCTestCase {
self.factory = factory
let client = factory.client.organization

/* Create organizations */
// Create organizations
var options: [VOOrganization.CreateOptions] = []
for index in 0..<6 {
options.append(.init(name: "Test Organization \(index)"))
Expand All @@ -29,40 +29,40 @@ final class OrganizationTests: XCTestCase {
try await organizations.append(factory.organization(options[index]))
}

/* Test creation */
// Test creation
for index in 0..<organizations.count {
XCTAssertEqual(organizations[index].name, options[index].name)
}

/* Test list */
// Test list

/* Page 1 */
// Page 1
let page1 = try await client.fetchList(.init(page: 1, size: 3))
XCTAssertGreaterThanOrEqual(page1.totalElements, options.count)
XCTAssertGreaterThanOrEqual(page1.totalPages, 2)
XCTAssertEqual(page1.page, 1)
XCTAssertEqual(page1.size, 3)
XCTAssertEqual(page1.data.count, page1.size)

/* Page 2 */
// Page 2
let page2 = try await client.fetchList(.init(page: 2, size: 3))
XCTAssertGreaterThanOrEqual(page2.totalElements, options.count)
XCTAssertEqual(page2.page, 2)
XCTAssertEqual(page2.size, 3)
XCTAssertEqual(page2.data.count, page2.size)

/* Test fetch */
// Test fetch
let organization = try await client.fetch(organizations[0].id)
XCTAssertEqual(organization.name, organizations[0].name)

/* Test patch name */
// Test patch name
let newName = "New Organization"
let alpha = try await client.patchName(organization.id, options: .init(name: newName))
XCTAssertEqual(alpha.name, newName)
let beta = try await factory.client.organization.fetch(organization.id)
XCTAssertEqual(beta.name, newName)

/* Test leave */
// Test leave
do {
try await client.leave(organization.id)
expectedToFail()
Expand All @@ -72,7 +72,7 @@ final class OrganizationTests: XCTestCase {
invalidError(error)
}

/* Test delete */
// Test delete
for organization in organizations {
try await client.delete(organization.id)
}
Expand Down
Loading

0 comments on commit d70109b

Please sign in to comment.