fn small_write()

in src/fs.rs [1006:1038]


    fn small_write<'a>() {
        init();

        let dir = tempfile::Builder::new()
            .prefix("mount_and_write")
            .tempdir()
            .unwrap();

        let mnt = dir.into_path();
        let mnt_str = String::from(mnt.to_str().unwrap());
        let daemon = mount_tempdir_rw(mnt);

        info!("mounted fs at {} in thread {:#?}", mnt_str, daemon);

        let mut tmp_file = NamedTempFile::new_in(mnt_str).unwrap();
        info!("Opened '{:#?}'", tmp_file.path());
        let txt_file = tmp_file.as_file_mut();

        let write_result = txt_file.write_all(b"My first words!");
        info!(" got back {:#?}", write_result);
        assert!(write_result.is_ok());
        // sync the file to see if we have any other errors.
        let sync_result = txt_file.sync_all();
        info!(" sync result => {:#?}", sync_result);
        assert!(sync_result.is_ok());
        // drop the file to close it.
        drop(txt_file);
        info!("Sleeping for 1s, to wait for the FS to be flush.");
        std::thread::sleep(Duration::from_millis(1000));

        // Drop the daemon to clean up.
        drop(daemon);
    }