Skip to content

Commit d99b1ca

Browse files
committed
update tests to use different fixtures
1 parent 03e822b commit d99b1ca

File tree

17 files changed

+78
-19
lines changed

17 files changed

+78
-19
lines changed

src/packs/configuration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ mod tests {
470470

471471
#[test]
472472
fn with_readme_template_path() {
473-
let absolute_root = PathBuf::from("tests/fixtures/simple_packs_first_app");
473+
let absolute_root = PathBuf::from("tests/fixtures/app_with_custom_readme");
474474
let actual = configuration::get(&absolute_root).unwrap();
475475

476476
let actual_readme_template_path = actual.readme_template_path;

tests/common/mod.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,22 @@ pub fn delete_foobar() {
3232
}
3333

3434
#[allow(dead_code)]
35-
pub fn delete_foobar_packs_first() {
36-
let directory = PathBuf::from("tests/fixtures/simple_packs_first_app/packs/foobar");
35+
pub fn delete_foobaz() {
36+
let directory = PathBuf::from("tests/fixtures/simple_packs_first_app/packs/foobaz");
3737
if let Err(err) = fs::remove_dir_all(directory) {
3838
eprintln!(
39-
"Failed to remove tests/fixtures/simple_packs_first_app/packs/foobar during test teardown: {}",
39+
"Failed to remove tests/fixtures/simple_packs_first_app/packs/foobaz during test teardown: {}",
40+
err
41+
);
42+
}
43+
}
44+
45+
#[allow(dead_code)]
46+
pub fn delete_foobar_app_with_custom_readme() {
47+
let directory = PathBuf::from("tests/fixtures/app_with_custom_readme/packs/foobar");
48+
if let Err(err) = fs::remove_dir_all(directory) {
49+
eprintln!(
50+
"Failed to remove tests/fixtures/app_with_custom_readme/packs/foobar during test teardown: {}",
4051
err
4152
);
4253
}

tests/create_test.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,40 +68,40 @@ See https://github.com/rubyatscale/pks#readme for more info!");
6868

6969
#[test]
7070
fn test_create_with_readme_template_default_path() -> Result<(), Box<dyn Error>> {
71-
common::delete_foobar();
71+
common::delete_foobaz();
7272

73-
fs::write("tests/fixtures/simple_app/README_TEMPLATE.md", "This is a test custom README template")?;
73+
fs::write("tests/fixtures/simple_packs_first_app/README_TEMPLATE.md", "This is a test custom README template")?;
7474

7575
Command::cargo_bin("pks")?
7676
.arg("--project-root")
77-
.arg("tests/fixtures/simple_app")
77+
.arg("tests/fixtures/simple_packs_first_app")
7878
.arg("create")
79-
.arg("packs/foobar")
79+
.arg("packs/foobaz")
8080
.assert()
8181
.success();
8282

8383
let expected_readme = String::from("This is a test custom README template");
8484
let actual_readme =
85-
fs::read_to_string("tests/fixtures/simple_app/packs/foobar/README.md").unwrap_or_else(|e| {
86-
panic!("Could not read file tests/fixtures/simple_app/packs/foobar/README.md: {}", e)
85+
fs::read_to_string("tests/fixtures/simple_packs_first_app/packs/foobaz/README.md").unwrap_or_else(|e| {
86+
panic!("Could not read file tests/fixtures/simple_packs_first_app/packs/foobaz/README.md: {}", e)
8787
});
8888

8989
assert_eq!(expected_readme, actual_readme);
9090

9191
common::teardown();
92-
common::delete_foobar();
93-
fs::remove_file("tests/fixtures/simple_app/README_TEMPLATE.md")?;
92+
common::delete_foobaz();
93+
fs::remove_file("tests/fixtures/simple_packs_first_app/README_TEMPLATE.md")?;
9494

9595
Ok(())
9696
}
9797

9898
#[test]
9999
fn test_create_with_readme_template_custom_path() -> Result<(), Box<dyn Error>> {
100-
common::delete_foobar_packs_first();
100+
common::delete_foobar_app_with_custom_readme();
101101

102102
Command::cargo_bin("pks")?
103103
.arg("--project-root")
104-
.arg("tests/fixtures/simple_packs_first_app")
104+
.arg("tests/fixtures/app_with_custom_readme")
105105
.arg("create")
106106
.arg("packs/foobar")
107107
.assert()
@@ -110,14 +110,14 @@ fn test_create_with_readme_template_custom_path() -> Result<(), Box<dyn Error>>
110110
let expected_readme = String::from("README template\n\nThis is a test\n");
111111

112112
let actual_readme =
113-
fs::read_to_string("tests/fixtures/simple_packs_first_app/packs/foobar/README.md").unwrap_or_else(|e| {
114-
panic!("Could not read file tests/fixtures/simple_packs_first_app/packs/foobar/README.md: {}", e)
113+
fs::read_to_string("tests/fixtures/app_with_custom_readme/packs/foobar/README.md").unwrap_or_else(|e| {
114+
panic!("Could not read file tests/fixtures/app_with_custom_readme/packs/foobar/README.md: {}", e)
115115
});
116116

117117
assert_eq!(expected_readme, actual_readme);
118118

119119
common::teardown();
120-
common::delete_foobar_packs_first();
120+
common::delete_foobar_app_with_custom_readme();
121121

122122
Ok(())
123123
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
class SomeRootClass; end

tests/fixtures/app_with_custom_readme/package.yml

Whitespace-only changes.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# See: Setting up the configuration file
2+
# https://github.com/Shopify/packwerk/blob/main/USAGE.md#setting-up-the-configuration-file
3+
4+
# List of patterns for folder paths to include
5+
# include:
6+
# - "**/*.{rb,rake,erb}"
7+
8+
# List of patterns for folder paths to exclude
9+
# exclude:
10+
# - "{bin,node_modules,script,tmp,vendor}/**/*"
11+
12+
# Patterns to find package configuration files
13+
# package_paths: "**/"
14+
15+
# List of custom associations, if any
16+
# custom_associations:
17+
# - "cache_belongs_to"
18+
19+
# Whether or not you want the cache enabled (disabled by default)
20+
cache: false
21+
22+
# Where you want the cache to be stored (default below)
23+
# cache_directory: 'tmp/cache/packwerk'
24+
25+
readme_template_path: config/packs/README_EXAMPLE.md
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module SomeConcern; end
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module Bar
2+
def bar; end
3+
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
enforce_privacy: true

0 commit comments

Comments
 (0)