28 lines
		
	
	
		
			756 B
		
	
	
	
		
			Rust
		
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			756 B
		
	
	
	
		
			Rust
		
	
	
	
use assert_cmd::prelude::*; // Add methods on commands
 | 
						|
use predicates::prelude::*; // Used for writing assertions
 | 
						|
use std::process::Command; // Run programs
 | 
						|
 | 
						|
#[test]
 | 
						|
fn file_doesnt_exist() -> Result<(), Box<dyn std::error::Error>> {
 | 
						|
    let mut cmd = Command::cargo_bin("mox")?;
 | 
						|
 | 
						|
    cmd.arg("scan").arg("--file").arg("test.moxy");
 | 
						|
    cmd.assert()
 | 
						|
        .failure()
 | 
						|
        .stderr(predicate::str::contains("No such file or directory"));
 | 
						|
 | 
						|
    Ok(())
 | 
						|
}
 | 
						|
 | 
						|
#[test]
 | 
						|
fn scan_file_succeeds() -> Result<(), Box<dyn std::error::Error>> {
 | 
						|
    let mut cmd = Command::cargo_bin("mox")?;
 | 
						|
 | 
						|
    cmd.arg("scan").arg("--file").arg("test.mox");
 | 
						|
    cmd.assert().success().stdout(predicate::str::contains(
 | 
						|
        "1:0   TokenFalse           \"no\"",
 | 
						|
    ));
 | 
						|
 | 
						|
    Ok(())
 | 
						|
}
 |