Use pretty_assertions in tests
This commit is contained in:
		
							parent
							
								
									70c8d0f763
								
							
						
					
					
						commit
						933eb1ac40
					
				
					 2 changed files with 29 additions and 30 deletions
				
			
		|  | @ -10,3 +10,6 @@ edition = "2018" | ||||||
| serde = { version = "1.0", features = ["derive"] } | serde = { version = "1.0", features = ["derive"] } | ||||||
| serde_json = "1.0" | serde_json = "1.0" | ||||||
| schemars_derive = { version = "0.1.0", path = "../schemars_derive" } | schemars_derive = { version = "0.1.0", path = "../schemars_derive" } | ||||||
|  | 
 | ||||||
|  | [dev-dependencies] | ||||||
|  | pretty_assertions = "0.6.1" | ||||||
|  |  | ||||||
|  | @ -1,12 +1,9 @@ | ||||||
|  | use pretty_assertions::assert_eq; | ||||||
| use schemars::schema::*; | use schemars::schema::*; | ||||||
| use schemars::{gen, schema_for}; | use schemars::{gen, schema_for}; | ||||||
| use serde_json::{from_str, to_string_pretty}; | use serde_json::{from_str, to_string_pretty}; | ||||||
| use std::fs; | use std::fs; | ||||||
| 
 | 
 | ||||||
| #[cfg(test)] |  | ||||||
| mod tests { |  | ||||||
|     use super::*; |  | ||||||
| 
 |  | ||||||
| #[test] | #[test] | ||||||
| fn schema_matches_default_settings() -> Result<(), Box<dyn std::error::Error>> { | fn schema_matches_default_settings() -> Result<(), Box<dyn std::error::Error>> { | ||||||
|     let expected_json = fs::read_to_string("tests/schema.json")?; |     let expected_json = fs::read_to_string("tests/schema.json")?; | ||||||
|  | @ -15,7 +12,7 @@ mod tests { | ||||||
|     let actual = schema_for!(Schema); |     let actual = schema_for!(Schema); | ||||||
|     fs::write("tests/schema.actual.json", to_string_pretty(&actual)?)?; |     fs::write("tests/schema.actual.json", to_string_pretty(&actual)?)?; | ||||||
| 
 | 
 | ||||||
|         assert_eq!(actual, expected, "\n\nGenerated schema did not match saved schema - generated schema has been written to \"tests/schema.actual.json\"."); |     assert_eq!(actual, expected, "Generated schema did not match saved schema - generated schema has been written to \"tests/schema.actual.json\"."); | ||||||
|     Ok(()) |     Ok(()) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -32,7 +29,6 @@ mod tests { | ||||||
|         to_string_pretty(&actual)?, |         to_string_pretty(&actual)?, | ||||||
|     )?; |     )?; | ||||||
| 
 | 
 | ||||||
|         assert_eq!(actual, expected, "\n\nGenerated schema did not match saved schema - generated schema has been written to \"tests/schema-openapi3.actual.json\"."); |     assert_eq!(actual, expected, "Generated schema did not match saved schema - generated schema has been written to \"tests/schema-openapi3.actual.json\"."); | ||||||
|     Ok(()) |     Ok(()) | ||||||
| } | } | ||||||
| } |  | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Graham Esau
						Graham Esau