Skip to content

Add filesystem integration tests for ProjectBrowserClients #3

@elkraneo

Description

@elkraneo

Summary

Add integration tests for FileOperationsClient and AssetDiscoveryClient that exercise actual filesystem operations using a temporary directory.

Motivation

The current unit tests mock the clients to test reducer logic. Integration tests would catch edge cases in the actual file operations:

  • Name collision handling (uniqueURL)
  • Permission errors
  • Symlink handling
  • Unicode filenames
  • Case sensitivity on different filesystems

Proposed Tests

FileOperationsClient

@Test func move_handlesNameCollision() async throws {
    let temp = FileManager.default.temporaryDirectory.appending(component: UUID().uuidString)
    defer { try? FileManager.default.removeItem(at: temp) }
    
    // Setup: create file and folder with existing file of same name
    try FileManager.default.createDirectory(at: temp, withIntermediateDirectories: true)
    let source = temp.appending(component: "test.usda")
    let folder = temp.appending(component: "Folder")
    let existing = folder.appending(component: "test.usda")
    try "source".write(to: source, atomically: true, encoding: .utf8)
    try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: false)
    try "existing".write(to: existing, atomically: true, encoding: .utf8)
    
    // Test
    let client = FileOperationsClient.liveValue
    let result = try await client.move([source], folder)
    
    // Should create "test 2.usda" due to collision
    #expect(result[source]?.lastPathComponent == "test 2.usda")
}

AssetDiscoveryClient

@Test func discover_findsNestedAssets() async throws {
    // Create a temp .rkassets structure with nested folders
    // Verify recursive scanning works correctly
}

Acceptance Criteria

  • Tests use isolated temp directories (no interference between runs)
  • Cleanup via defer even on test failure
  • Cover: create, rename, move, delete, duplicate, import
  • Cover: discovery with empty folders, nested folders, hidden files

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions