1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// =============================================================================
// Copyright (c) 2026 Haixing Hu.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0.
// =============================================================================
//! Owned write requests prepared independently of the operation under test.
use qubit_fs::path::Path;
use qubit_fs::write::WriteOptions;
/// A write request; its expected behavior is determined by `WriteScenario`.
///
/// Fixtures supply representable requests, never weaker expected results.
///
/// # Examples
///
/// ```
/// use qubit_fs::path::Path;
/// use qubit_fs::write::{WriteDisposition, WriteOptions};
/// use qubit_fs_testkit::WriteFixtureCase;
///
/// let request = WriteFixtureCase::new(
/// Path::parse("/isolated/write")?,
/// b"payload".to_vec(),
/// WriteOptions::default().with_disposition(WriteDisposition::CreateNew),
/// );
/// assert_eq!(request.bytes(), b"payload");
/// # Ok::<(), qubit_fs::error::FsError>(())
/// ```
#[must_use]
#[derive(Clone, Debug)]
pub struct WriteFixtureCase {
path: Path,
bytes: Vec<u8>,
options: WriteOptions,
}
impl WriteFixtureCase {
/// Creates an owned request for the selected scenario.
pub fn new(path: Path, bytes: Vec<u8>, options: WriteOptions) -> Self {
Self { path, bytes, options }
}
/// Returns the destination mapped into the fixture's isolated namespace.
pub const fn path(&self) -> &Path {
&self.path
}
/// Returns the payload the suite will verify independently.
pub fn bytes(&self) -> &[u8] {
&self.bytes
}
/// Returns the requested disposition, preconditions, and guarantees.
pub const fn options(&self) -> &WriteOptions {
&self.options
}
}