Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logical package yml serialization #9

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/packs/pack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ use super::{

#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
pub struct Pack {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub owner: Option<String>,

#[serde(skip)]
pub yml: PathBuf,

Expand All @@ -32,7 +35,7 @@ pub struct Pack {
serialize_with = "serialize_checker_setting",
deserialize_with = "deserialize_checker_setting"
)]
pub enforce_dependencies: Option<CheckerSetting>,
pub enforce_folder_privacy: Option<CheckerSetting>,

#[serde(
default,
Expand All @@ -58,12 +61,17 @@ pub struct Pack {
)]
pub enforce_layers: Option<CheckerSetting>,

#[serde(default, skip_serializing_if = "Option::is_none")]
pub owner: Option<String>,

#[serde(default, skip_serializing_if = "Option::is_none")]
pub layer: Option<String>,

#[serde(
default,
skip_serializing_if = "Option::is_none",
serialize_with = "serialize_checker_setting",
deserialize_with = "deserialize_checker_setting"
)]
pub enforce_dependencies: Option<CheckerSetting>,

#[serde(
default,
skip_serializing_if = "HashSet::is_empty",
Expand Down Expand Up @@ -102,14 +110,6 @@ pub struct Pack {
)]
pub visible_to: Option<HashSet<String>>,

#[serde(
default,
skip_serializing_if = "Option::is_none",
serialize_with = "serialize_checker_setting",
deserialize_with = "deserialize_checker_setting"
)]
pub enforce_folder_privacy: Option<CheckerSetting>,

#[serde(
default,
skip_serializing_if = "Option::is_none",
Expand Down Expand Up @@ -513,8 +513,8 @@ foobar: true
let actual = reserialize_pack(pack_yml);

let expected = r#"
enforce_dependencies: strict
enforce_privacy: true
enforce_dependencies: strict
dependencies:
- packs/a
- packs/b
Expand Down Expand Up @@ -626,8 +626,8 @@ enforce_dependencies: true
let actual = reserialize_pack(pack_yml);

let expected = r#"
enforce_dependencies: true
owner: Foobar
enforce_dependencies: true
"#
.trim_start();

Expand Down
2 changes: 1 addition & 1 deletion tests/check_unused_dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ fn assert_auto_correct_unused_dependencies(
.success();

let expected_autocorrect = [
"enforce_dependencies: true",
"enforce_privacy: true",
"layer: technical_services",
"enforce_dependencies: true",
"dependencies:",
"- packs/bar\n",
]
Expand Down
2 changes: 2 additions & 0 deletions tests/create_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ mod common;

#[test]
fn test_create() -> Result<(), Box<dyn Error>> {
common::delete_foobar();

Command::cargo_bin("pks")?
.arg("--project-root")
.arg("tests/fixtures/simple_app")
Expand Down
Loading