Skip to content

Commit

Permalink
fix: table tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Barsik-sus committed Dec 13, 2023
1 parent ddb60f1 commit 87f21ca
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions module/move/willbe/tests/inc/endpoints/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mod table_create_test
}

#[ test ]
// should panic, because the url to the repository is not in Cargo.toml of the workspace or in Cargo.toml of the module.
// should panic, because the url to the repository is not in Cargo.toml of the workspace or in Cargo.toml of the module.
fn without_any_toml_configurations_test()
{
// Arrange
Expand All @@ -34,12 +34,12 @@ mod table_create_test
}

#[ test ]
// url to repository and list of branches should be taken from workspace Cargo.toml, stability - experimental by default
// url to repository and list of branches should be taken from workspace Cargo.toml, stability - experimental by default
fn without_module_toml_configurations_test()
{
// Arrange
let expected =
"<!--{ generate.healthtable( '.' ) } -->\r| Module | Stability | test_branch1 | test_branch2 | Docs | Sample |\n|--------|-----------|--------|--------|:----:|:------:|\n| [c](./c) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Username/test/ModuleCPush.yml?label=&branch=test_branch1)](https://https://github.com/Username/test/actions/workflows/ModuleCPush.yml) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Username/test/ModuleCPush.yml?label=&branch=test_branch2)](https://https://github.com/Username/test/actions/workflows/ModuleCPush.yml) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/c) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fc_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20c_trivial_sample/https://github.com/Username/test) | \n<!--{ generate.healthtable.end } -->\r\n\r\n";
let expected =
"<!--{ generate.healthtable( '.' ) } -->\r| Module | Stability | test_branch1 | test_branch2 | Docs | Sample |\n|--------|-----------|--------|--------|:----:|:------:|\n| [_willbe_without_module_toml_configurations_c](./_willbe_without_module_toml_configurations_c) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Username/test/ModuleWillbeWithoutModuleTomlConfigurationsCPush.yml?label=&branch=test_branch1)](https://https://github.com/Username/test/actions/workflows/ModuleWillbeWithoutModuleTomlConfigurationsCPush.yml) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Username/test/ModuleWillbeWithoutModuleTomlConfigurationsCPush.yml?label=&branch=test_branch2)](https://https://github.com/Username/test/actions/workflows/ModuleWillbeWithoutModuleTomlConfigurationsCPush.yml) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/_willbe_without_module_toml_configurations_c) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2F_willbe_without_module_toml_configurations_c_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20_willbe_without_module_toml_configurations_c_trivial_sample/https://github.com/Username/test) | \n<!--{ generate.healthtable.end } -->\r\n\r\n";
let temp = arrange( "without_module_toml_configurations" );

// Act
Expand All @@ -53,12 +53,12 @@ mod table_create_test
}

#[ test ]
// url to repository and stability should be taken from module Cargo.toml, branches should not be awarded because they are not listed in the workspace Cargo.toml
// url to repository and stability should be taken from module Cargo.toml, branches should not be awarded because they are not listed in the workspace Cargo.toml
fn without_workspace_toml_configurations_test()
{
// Arrange
let expected =
"<!--{ generate.healthtable( '.' ) } -->\r| Module | Stability | Docs | Sample |\n|--------|-----------|:----:|:------:|\n| [c](./c) |[![stability-stable](https://img.shields.io/badge/stability-stable-green.svg)](https://github.com/emersion/stability-badges#stable) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/c) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fc_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20c_trivial_sample/https://github.com/Testusername/TestProject) | \n<!--{ generate.healthtable.end } -->\r\n\r\n";
let expected =
"<!--{ generate.healthtable( '.' ) } -->\r| Module | Stability | Docs | Sample |\n|--------|-----------|:----:|:------:|\n| [_willbe_without_workspace_toml_configurations_c](./_willbe_without_workspace_toml_configurations_c) |[![stability-stable](https://img.shields.io/badge/stability-stable-green.svg)](https://github.com/emersion/stability-badges#stable) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/_willbe_without_workspace_toml_configurations_c) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2F_willbe_without_workspace_toml_configurations_c_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20_willbe_without_workspace_toml_configurations_c_trivial_sample/https://github.com/Testusername/TestProject) | \n<!--{ generate.healthtable.end } -->\r\n\r\n";
let temp = arrange( "without_workspace_toml_configurations" );

// Act
Expand All @@ -72,21 +72,21 @@ mod table_create_test
}

#[ test ]
fn variadic_tag_configuration_test()
fn variadic_tag_configuration_test()
{
// Arrange
let explicit_all_true_flag =
"<!--{ generate.healthtable( path: '.', with_stability : 1, with_branches : 1, with_docs : 1, with_gitpod : 1 ) } -->\r| Module | Stability | test_branch1 | test_branch2 | Docs | Sample |\n|--------|-----------|--------|--------|:----:|:------:|\n| [c](./c) |[![stability-deprecated](https://img.shields.io/badge/stability-deprecated-red.svg)](https://github.com/emersion/stability-badges#deprecated) | [![rust-status](https://img.shields.io/github/actions/workflow/status/SomeCrate/C/ModuleCPush.yml?label=&branch=test_branch1)](https://https://github.com/SomeName/SomeCrate/C/actions/workflows/ModuleCPush.yml) | [![rust-status](https://img.shields.io/github/actions/workflow/status/SomeCrate/C/ModuleCPush.yml?label=&branch=test_branch2)](https://https://github.com/SomeName/SomeCrate/C/actions/workflows/ModuleCPush.yml) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/c) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fc_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20c_trivial_sample/https://github.com/SomeName/SomeCrate/C) | \n<!--{ generate.healthtable.end } -->";
let all_true_flag =
"<!--{ generate.healthtable( '.' ) } -->\r| Module | Stability | test_branch1 | test_branch2 | Docs | Sample |\n|--------|-----------|--------|--------|:----:|:------:|\n| [c](./c) |[![stability-deprecated](https://img.shields.io/badge/stability-deprecated-red.svg)](https://github.com/emersion/stability-badges#deprecated) | [![rust-status](https://img.shields.io/github/actions/workflow/status/SomeCrate/C/ModuleCPush.yml?label=&branch=test_branch1)](https://https://github.com/SomeName/SomeCrate/C/actions/workflows/ModuleCPush.yml) | [![rust-status](https://img.shields.io/github/actions/workflow/status/SomeCrate/C/ModuleCPush.yml?label=&branch=test_branch2)](https://https://github.com/SomeName/SomeCrate/C/actions/workflows/ModuleCPush.yml) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/c) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fc_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20c_trivial_sample/https://github.com/SomeName/SomeCrate/C) | \n<!--{ generate.healthtable.end } -->";
let with_stability_only =
"<!--{ generate.healthtable( path: '.', with_stability : 1, with_branches : 0, with_docs : 0, with_gitpod : 0 ) } -->\r| Module | Stability |\n|--------|-----------|\n| [c](./c) |[![stability-deprecated](https://img.shields.io/badge/stability-deprecated-red.svg)](https://github.com/emersion/stability-badges#deprecated) | \n<!--{ generate.healthtable.end } -->";
let explicit_all_true_flag =
"<!--{ generate.healthtable( path: '.', with_stability : 1, with_branches : 1, with_docs : 1, with_gitpod : 1 ) } -->\r| Module | Stability | test_branch1 | test_branch2 | Docs | Sample |\n|--------|-----------|--------|--------|:----:|:------:|\n| [_willbe_variadic_tag_configurations_c](./_willbe_variadic_tag_configurations_c) |[![stability-deprecated](https://img.shields.io/badge/stability-deprecated-red.svg)](https://github.com/emersion/stability-badges#deprecated) | [![rust-status](https://img.shields.io/github/actions/workflow/status/SomeCrate/C/ModuleWillbeVariadicTagConfigurationsCPush.yml?label=&branch=test_branch1)](https://https://github.com/SomeName/SomeCrate/C/actions/workflows/ModuleWillbeVariadicTagConfigurationsCPush.yml) | [![rust-status](https://img.shields.io/github/actions/workflow/status/SomeCrate/C/ModuleWillbeVariadicTagConfigurationsCPush.yml?label=&branch=test_branch2)](https://https://github.com/SomeName/SomeCrate/C/actions/workflows/ModuleWillbeVariadicTagConfigurationsCPush.yml) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/_willbe_variadic_tag_configurations_c) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2F_willbe_variadic_tag_configurations_c_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20_willbe_variadic_tag_configurations_c_trivial_sample/https://github.com/SomeName/SomeCrate/C) | \n<!--{ generate.healthtable.end } -->";
let all_true_flag =
"<!--{ generate.healthtable( '.' ) } -->\r| Module | Stability | test_branch1 | test_branch2 | Docs | Sample |\n|--------|-----------|--------|--------|:----:|:------:|\n| [_willbe_variadic_tag_configurations_c](./_willbe_variadic_tag_configurations_c) |[![stability-deprecated](https://img.shields.io/badge/stability-deprecated-red.svg)](https://github.com/emersion/stability-badges#deprecated) | [![rust-status](https://img.shields.io/github/actions/workflow/status/SomeCrate/C/ModuleWillbeVariadicTagConfigurationsCPush.yml?label=&branch=test_branch1)](https://https://github.com/SomeName/SomeCrate/C/actions/workflows/ModuleWillbeVariadicTagConfigurationsCPush.yml) | [![rust-status](https://img.shields.io/github/actions/workflow/status/SomeCrate/C/ModuleWillbeVariadicTagConfigurationsCPush.yml?label=&branch=test_branch2)](https://https://github.com/SomeName/SomeCrate/C/actions/workflows/ModuleWillbeVariadicTagConfigurationsCPush.yml) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/_willbe_variadic_tag_configurations_c) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2F_willbe_variadic_tag_configurations_c_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20_willbe_variadic_tag_configurations_c_trivial_sample/https://github.com/SomeName/SomeCrate/C) | \n<!--{ generate.healthtable.end } -->";
let with_stability_only =
"<!--{ generate.healthtable( path: '.', with_stability : 1, with_branches : 0, with_docs : 0, with_gitpod : 0 ) } -->\r| Module | Stability |\n|--------|-----------|\n| [_willbe_variadic_tag_configurations_c](./_willbe_variadic_tag_configurations_c) |[![stability-deprecated](https://img.shields.io/badge/stability-deprecated-red.svg)](https://github.com/emersion/stability-badges#deprecated) | \n<!--{ generate.healthtable.end } -->";
let with_branches_only =
"<!--{ generate.healthtable( path: '.', with_stability : 0, with_branches : 1, with_docs : 0, with_gitpod : 0 ) } -->\r| Module | test_branch1 | test_branch2 |\n|--------|--------|--------|\n| [c](./c) |[![rust-status](https://img.shields.io/github/actions/workflow/status/SomeCrate/C/ModuleCPush.yml?label=&branch=test_branch1)](https://https://github.com/SomeName/SomeCrate/C/actions/workflows/ModuleCPush.yml) | [![rust-status](https://img.shields.io/github/actions/workflow/status/SomeCrate/C/ModuleCPush.yml?label=&branch=test_branch2)](https://https://github.com/SomeName/SomeCrate/C/actions/workflows/ModuleCPush.yml) | \n<!--{ generate.healthtable.end } -->";
let with_docs_only =
"<!--{ generate.healthtable( path: '.', with_stability : 0, with_branches : 0, with_docs : 1, with_gitpod : 0 ) } -->\r| Module | Docs |\n|--------|:----:|\n| [c](./c) |[![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/c) | \n<!--{ generate.healthtable.end } -->";
let with_gitpod_only =
"<!--{ generate.healthtable( path: '.', with_stability : 0, with_branches : 0, with_docs : 0, with_gitpod : 1 ) } -->\r| Module | Sample |\n|--------|:------:|\n| [c](./c) |[![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fc_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20c_trivial_sample/https://github.com/SomeName/SomeCrate/C) | \n<!--{ generate.healthtable.end } -->";
"<!--{ generate.healthtable( path: '.', with_stability : 0, with_branches : 1, with_docs : 0, with_gitpod : 0 ) } -->\r| Module | test_branch1 | test_branch2 |\n|--------|--------|--------|\n| [_willbe_variadic_tag_configurations_c](./_willbe_variadic_tag_configurations_c) |[![rust-status](https://img.shields.io/github/actions/workflow/status/SomeCrate/C/ModuleWillbeVariadicTagConfigurationsCPush.yml?label=&branch=test_branch1)](https://https://github.com/SomeName/SomeCrate/C/actions/workflows/ModuleWillbeVariadicTagConfigurationsCPush.yml) | [![rust-status](https://img.shields.io/github/actions/workflow/status/SomeCrate/C/ModuleWillbeVariadicTagConfigurationsCPush.yml?label=&branch=test_branch2)](https://https://github.com/SomeName/SomeCrate/C/actions/workflows/ModuleWillbeVariadicTagConfigurationsCPush.yml) | \n<!--{ generate.healthtable.end } -->";
let with_docs_only =
"<!--{ generate.healthtable( path: '.', with_stability : 0, with_branches : 0, with_docs : 1, with_gitpod : 0 ) } -->\r| Module | Docs |\n|--------|:----:|\n| [_willbe_variadic_tag_configurations_c](./_willbe_variadic_tag_configurations_c) |[![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/_willbe_variadic_tag_configurations_c) | \n<!--{ generate.healthtable.end } -->";
let with_gitpod_only =
"<!--{ generate.healthtable( path: '.', with_stability : 0, with_branches : 0, with_docs : 0, with_gitpod : 1 ) } -->\r| Module | Sample |\n|--------|:------:|\n| [_willbe_variadic_tag_configurations_c](./_willbe_variadic_tag_configurations_c) |[![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2F_willbe_variadic_tag_configurations_c_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20_willbe_variadic_tag_configurations_c_trivial_sample/https://github.com/SomeName/SomeCrate/C) | \n<!--{ generate.healthtable.end } -->";

let expected = vec![ explicit_all_true_flag, all_true_flag, with_stability_only, with_branches_only, with_docs_only, with_gitpod_only ];
let temp = arrange( "variadic_tag_configurations" );
Expand All @@ -98,9 +98,9 @@ mod table_create_test
let mut file = std::fs::File::open( temp.path().join( "readme.md" ) ).unwrap();
let mut content = String::new();
_ = file.read_to_string( &mut content ).unwrap();
for ( index, actual ) in content.split( "###" ).into_iter().enumerate()
for ( index, actual ) in content.split( "###" ).into_iter().enumerate()
{
assert_eq!( expected[ index ], actual.trim() );
assert_eq!( expected[ index ], actual.trim() );
}
}

Expand Down

0 comments on commit 87f21ca

Please sign in to comment.