use crate :: *;
use assert_fs ::prelude :: *;
use the_module ::action;
use std ::io ::Read;
use willbe ::path ::AbsolutePath;
fn arrange( source: &str ) -> assert_fs ::TempDir
{
let root_path = std ::path ::Path ::new( env!( "CARGO_MANIFEST_DIR" ) );
let assets_relative_path = std ::path ::Path ::new( ASSET_PATH );
let assets_path = root_path.join( assets_relative_path );
let temp = assert_fs ::TempDir ::new().unwrap();
temp.copy_from( assets_path.join( source ), &[ "**" ] ).unwrap();
temp
}
#[ test ]
fn tag_shout_stay()
{
let temp = arrange( "single_module" );
_ = action ::readme_header_renew ::orphan ::readme_header_renew( AbsolutePath ::try_from( temp.path() ).unwrap() ).unwrap();
let mut file = std ::fs ::File ::open( temp.path().join( "readme.md" ) ).unwrap();
let mut actual = String ::new();
_ = file.read_to_string( &mut actual ).unwrap();
assert!( actual.contains( "< !--{ generate.main_header.start() }-- >" ) );
assert!( actual.contains( "< !--{ generate.main_header.end }-- >" ) );
}
#[ test ]
fn branch_cell()
{
let temp = arrange( "single_module" );
_ = action ::readme_header_renew ::orphan ::readme_header_renew( AbsolutePath ::try_from( temp.path() ).unwrap() ).unwrap();
let mut file = std ::fs ::File ::open( temp.path().join( "readme.md" ) ).unwrap();
let mut actual = String ::new();
_ = file.read_to_string( &mut actual ).unwrap();
assert!( actual.contains( "[](https: //github.com/Username/test/actions/workflows/StandardRustStatus.yml)" ) );
}
#[ test ]
fn discord_cell()
{
let temp = arrange( "single_module" );
_ = action ::readme_header_renew ::orphan ::readme_header_renew( AbsolutePath ::try_from( temp.path() ).unwrap() ).unwrap();
let mut file = std ::fs ::File ::open( temp.path().join( "readme.md" ) ).unwrap();
let mut actual = String ::new();
_ = file.read_to_string( &mut actual ).unwrap();
assert!( actual.contains( "[](https: //discord.gg/m3YfbXpUUY)" ) );
}
#[ test ]
fn gitpod_cell()
{
let temp = arrange( "single_module" );
_ = action ::readme_header_renew ::orphan ::readme_header_renew( AbsolutePath ::try_from( temp.path() ).unwrap() ).unwrap();
let mut file = std ::fs ::File ::open( temp.path().join( "readme.md" ) ).unwrap();
let mut actual = String ::new();
_ = file.read_to_string( &mut actual ).unwrap();
assert!( actual.contains( "[](https: //gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Ftest_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20test_trivial/https: //github.com/Username/test)" ) );
}
#[ test ]
fn docs_cell()
{
let temp = arrange( "single_module" );
_ = action ::readme_header_renew ::orphan ::readme_header_renew( AbsolutePath ::try_from( temp.path() ).unwrap() ).unwrap();
let mut file = std ::fs ::File ::open( temp.path().join( "readme.md" ) ).unwrap();
let mut actual = String ::new();
_ = file.read_to_string( &mut actual ).unwrap();
assert!( actual.contains( "[](https: //docs.rs/test)" ) );
}
#[ test ]
fn without_fool_config()
{
let temp = arrange( "single_module_without_master_branch_and_discord" );
_ = action ::readme_header_renew ::orphan ::readme_header_renew( AbsolutePath ::try_from( temp.path() ).unwrap() ).unwrap();
let mut file = std ::fs ::File ::open( temp.path().join( "readme.md" ) ).unwrap();
let mut actual = String ::new();
_ = file.read_to_string( &mut actual ).unwrap();
assert!( actual.contains( "[master]" ) ); assert!( !actual.contains( "[discord]" ) );}
#[ test ]
fn idempotency()
{
let temp = arrange( "single_module" );
_ = action ::readme_header_renew ::orphan ::readme_header_renew( AbsolutePath ::try_from( temp.path() ).unwrap() ).unwrap();
let mut file = std ::fs ::File ::open( temp.path().join( "readme.md" ) ).unwrap();
let mut actual1 = String ::new();
_ = file.read_to_string( &mut actual1 ).unwrap();
drop( file );
_ = action ::readme_header_renew ::orphan ::readme_header_renew( AbsolutePath ::try_from( temp.path() ).unwrap() ).unwrap();
let mut file = std ::fs ::File ::open( temp.path().join( "readme.md" ) ).unwrap();
let mut actual2 = String ::new();
_ = file.read_to_string( &mut actual2 ).unwrap();
drop( file );
assert_eq!( actual1, actual2 );
}
#[ test ]
#[ should_panic ]
fn without_needed_config()
{
let temp = arrange( "variadic_tag_configurations" );
_ = action ::readme_header_renew ::orphan ::readme_header_renew( AbsolutePath ::try_from( temp.path() ).unwrap() ).unwrap();
}