-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
!PATCHED! testing fitsio file_path api
- Loading branch information
Showing
5 changed files
with
48 additions
and
20 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use fitsio::FitsFile; | ||
|
||
use crate::io::read::fits::{fits_get_required_key, FitsError}; | ||
|
||
// check that the filename and key appear in the error struct | ||
#[test] | ||
fn test_fits_get_required_key() { | ||
let output = tempfile::NamedTempFile::new().unwrap(); | ||
|
||
// create a fits file with only header A | ||
{ | ||
let mut fitsfile = FitsFile::create(output.path()).overwrite().open().unwrap(); | ||
let hdu = fitsfile.primary_hdu().unwrap(); | ||
hdu.write_key(&mut fitsfile, "A", "1").unwrap(); | ||
} | ||
|
||
let mut fitsfile = FitsFile::edit(output.path()).unwrap(); | ||
let hdu = fitsfile.primary_hdu().unwrap(); | ||
|
||
// read header B from the fits file (doesn't exist) | ||
let missing: Result<String, FitsError> = fits_get_required_key(&mut fitsfile, &hdu, "B"); | ||
|
||
assert!( | ||
matches!(missing, Err(FitsError::MissingKey { key, fits_filename, .. }) if key == Box::from("B") && fits_filename == Box::from(output.path())) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters