Skip to content

Commit 11c4bba

Browse files
committed
refactor: remove unnecessary test, but also the misleading default.
After all, what matters is the default.
1 parent cee3f09 commit 11c4bba

File tree

2 files changed

+0
-56
lines changed

2 files changed

+0
-56
lines changed

crates/but-settings/src/app_settings.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ pub struct GitHubOAuthAppSettings {
2424
#[serde(rename_all = "camelCase")]
2525
pub struct FeatureFlags {
2626
/// Enable the usage of V3 workspace APIs.
27-
#[serde(default = "default_true")]
2827
pub ws3: bool,
2928
/// Turn on the set a v3 version of checkout
3029
pub cv3: bool,
@@ -53,10 +52,6 @@ pub struct FeatureFlags {
5352
pub single_branch: bool,
5453
}
5554

56-
fn default_true() -> bool {
57-
true
58-
}
59-
6055
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
6156
#[serde(rename_all = "camelCase")]
6257
pub struct ExtraCsp {

crates/but-settings/src/persistence.rs

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ impl AppSettings {
5959
}
6060

6161
mod tests {
62-
use crate::app_settings::FeatureFlags;
63-
6462
#[test]
6563
fn ensure_default_settings_covers_all_fields() {
6664
let settings: serde_json::Value =
@@ -81,53 +79,4 @@ mod tests {
8179
}
8280
assert!(app_settings.is_ok())
8381
}
84-
85-
#[test]
86-
fn ensure_feature_flags_json_defaults_match_struct_defaults() {
87-
// Get the feature flags from the JSON defaults file
88-
let json_defaults: serde_json::Value =
89-
serde_json_lenient::from_str(crate::persistence::DEFAULTS).unwrap();
90-
let json_feature_flags = json_defaults
91-
.get("featureFlags")
92-
.expect("featureFlags should exist in defaults.jsonc");
93-
94-
// Create what the struct would look like with proper serde defaults
95-
// Based on the struct definition, most fields are false except ws3 which has #[serde(default = "default_true")]
96-
let expected_default_feature_flags = FeatureFlags {
97-
ws3: true, // This has #[serde(default = "default_true")] so it should be true
98-
cv3: false,
99-
undo: false,
100-
actions: false,
101-
butbot: false,
102-
rules: false,
103-
single_branch: false,
104-
};
105-
106-
// Serialize the expected default struct to JSON for comparison
107-
let expected_default_as_json: serde_json::Value = serde_json::to_value(&expected_default_feature_flags)
108-
.expect("Expected default FeatureFlags should be serializable");
109-
110-
// Compare the JSON values directly - this will catch extra fields like 'v3' that don't exist in the struct
111-
if *json_feature_flags != expected_default_as_json {
112-
println!("\n===========================================================================================");
113-
println!("FeatureFlags JSON defaults don't match the default struct serialization!");
114-
println!();
115-
println!("JSON from defaults.jsonc:");
116-
println!("{}", serde_json::to_string_pretty(json_feature_flags).unwrap());
117-
println!();
118-
println!("Expected default struct serialized:");
119-
println!("{}", serde_json::to_string_pretty(&expected_default_as_json).unwrap());
120-
println!();
121-
println!("This means the JSON defaults contain fields or values that don't match");
122-
println!("the FeatureFlags struct definition. Please update either:");
123-
println!("1. The defaults in 'crates/but-settings/assets/defaults.jsonc' (remove extra fields, fix values)");
124-
println!("2. The FeatureFlags struct in 'crates/but-settings/src/app_settings.rs' (add missing fields)");
125-
println!("===========================================================================================\n");
126-
}
127-
128-
assert_eq!(
129-
*json_feature_flags, expected_default_as_json,
130-
"FeatureFlags JSON defaults should match the expected default struct when serialized"
131-
);
132-
}
13382
}

0 commit comments

Comments
 (0)