Files
iccery-v2-mac/Tests/ICCeryCoreTests/TargetWorkflowViewModelTests.swift
gronodandDevin <158243242+devin-ai-integration[bot]@users.noreply.github.com> a30a8fc551 test(m9): complete migration of all remaining test suites to XCTest
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-11 21:29:16 +01:00

40 lines
1.3 KiB
Swift

import Foundation
import XCTest
@testable import ICCeryCore
@testable import ICCery
/// Dataset-import error contracts through the
/// `importMeasurementDataset(from:)` seam (issue #80): parser and I/O
/// failures must surface identically as a single `.error` Notice.
@MainActor
final class TargetWorkflowViewModelTests: XCTestCase {
func testMalformedDatasetNotice() throws {
let env = try TestAppEnvironment.make()
defer { env.cleanup() }
let vm = TargetWorkflowViewModel(environment: env.environment)
let bad = env.root.appendingPathComponent("broken.ti3")
try Data("this is not CGATS data".utf8).write(to: bad)
vm.importMeasurementDataset(from: bad)
let notice = try XCTUnwrap(vm.wizard.notice)
XCTAssertEqual(notice.kind, .error)
XCTAssertTrue(notice.text.hasPrefix("Import failed:"))
}
func testMissingDatasetNotice() throws {
let env = try TestAppEnvironment.make()
defer { env.cleanup() }
let vm = TargetWorkflowViewModel(environment: env.environment)
let missing = env.root.appendingPathComponent("does-not-exist.ti3")
vm.importMeasurementDataset(from: missing)
let notice = try XCTUnwrap(vm.wizard.notice)
XCTAssertEqual(notice.kind, .error)
XCTAssertTrue(notice.text.hasPrefix("Import failed:"))
}
}