Skip to content

Commit 5bf3d03

Browse files
Revert "Make partial the default for user-settings-file (#5442)"
This reverts commit bdd2cab.
1 parent bdd2cab commit 5bf3d03

2 files changed

Lines changed: 21 additions & 47 deletions

File tree

src/AppInstallerCLICore/Commands/DscUserSettingsFileResource.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "DscUserSettingsFileResource.h"
55
#include "DscComposableObject.h"
66
#include "Resources.h"
7-
#include "AppInstallerStrings.h"
87

98
using namespace AppInstaller::Utility::literals;
109
using namespace AppInstaller::Settings;
@@ -17,7 +16,7 @@ namespace AppInstaller::CLI
1716
namespace
1817
{
1918
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_FLAGS(SettingsProperty, Json::Value, Settings, "settings", DscComposablePropertyFlag::Required | DscComposablePropertyFlag::CopyToOutput, Resource::String::DscResourcePropertyDescriptionUserSettingsFileSettings);
20-
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_ENUM(ActionProperty, std::string, Action, "action", Resource::String::DscResourcePropertyDescriptionUserSettingsFileAction, ({ ACTION_PARTIAL, ACTION_FULL }), ACTION_PARTIAL);
19+
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_ENUM(ActionProperty, std::string, Action, "action", Resource::String::DscResourcePropertyDescriptionUserSettingsFileAction, ({ ACTION_PARTIAL, ACTION_FULL }), ACTION_FULL);
2120

2221
using UserSettingsFileResourceObject = DscComposableObject<StandardInDesiredStateProperty, SettingsProperty, ActionProperty>;
2322

@@ -39,6 +38,7 @@ namespace AppInstaller::CLI
3938

4039
void Get()
4140
{
41+
Output.Action(ACTION_FULL);
4242
Output.Settings(GetUserSettings());
4343
}
4444

@@ -64,14 +64,12 @@ namespace AppInstaller::CLI
6464
THROW_HR_IF(E_UNEXPECTED, !Input.Settings().has_value());
6565
if (!_resolvedInputUserSettings)
6666
{
67-
if(Input.Action().has_value() && Utility::CaseInsensitiveEquals(Input.Action().value(), ACTION_FULL))
67+
if(Input.Action() == ACTION_FULL)
6868
{
69-
Output.Action(ACTION_FULL);
7069
_resolvedInputUserSettings = Input.Settings();
7170
}
7271
else
7372
{
74-
Output.Action(ACTION_PARTIAL);
7573
_resolvedInputUserSettings = MergeUserSettingsFiles(*Input.Settings());
7674
}
7775
}

src/AppInstallerCLIE2ETests/DSCv3UserSettingsFileResourceCommand.cs

Lines changed: 18 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void Setup()
6161
}
6262

6363
/// <summary>
64-
/// Calls `get` on the `user-settings-file` resource.
64+
/// Calls `get` on the `user-settings` resource.
6565
/// </summary>
6666
[Test]
6767
public void UserSettingsFile_Get()
@@ -70,12 +70,12 @@ public void UserSettingsFile_Get()
7070
var getOutput = Get(new ());
7171

7272
Assert.IsNotNull(getOutput);
73-
Assert.IsNull(getOutput.Action);
73+
Assert.AreEqual(ActionPropertyValueFull, getOutput.Action);
7474
AssertSettingsAreEqual(expected, getOutput.Settings);
7575
}
7676

7777
/// <summary>
78-
/// Calls `set` on the `user-settings-file` resource with no diff.
78+
/// Calls `set` on the `user-settings` resource with no diff.
7979
/// </summary>
8080
/// <param name="action">The action value.</param>
8181
[Test]
@@ -90,13 +90,13 @@ public void UserSettingsFile_Set_NoDiff(string action)
9090
var expected = GetCurrentUserSettings();
9191

9292
Assert.IsNotNull(setOutput);
93-
Assert.AreEqual(action, setOutput.Action);
93+
Assert.AreEqual(ActionPropertyValueFull, setOutput.Action);
9494
AssertSettingsAreEqual(expected, setOutput.Settings);
9595
AssertDiffState(setDiff, []);
9696
}
9797

9898
/// <summary>
99-
/// Calls `set` on the `user-settings-file` resource to add fields.
99+
/// Calls `set` on the `user-settings` resource to add fields.
100100
/// </summary>
101101
/// <param name="action">The action value.</param>
102102
[Test]
@@ -114,37 +114,14 @@ public void UserSettingsFile_Set_AddFields(string action)
114114

115115
// Assert that the settings are added
116116
Assert.IsNotNull(setOutput);
117-
Assert.AreEqual(action, setOutput.Action);
117+
Assert.AreEqual(ActionPropertyValueFull, setOutput.Action);
118118
AssertMockProperties(setOutput.Settings, "mock");
119119
AssertSettingsAreEqual(expected, setOutput.Settings);
120120
AssertDiffState(setDiff, [ SettingsPropertyName ]);
121121
}
122122

123123
/// <summary>
124-
/// Calls `set` on the `user-settings-file` resource to ensure action is partial by default.
125-
/// </summary>
126-
[Test]
127-
public void UserSettingsFile_Set_ActionIsPartialByDefault()
128-
{
129-
// Call `set` to add mock properties to the settings
130-
var setSettings = GetSettingsArg(ActionPropertyValuePartial);
131-
AddOrModifyMockProperties(setSettings, "mock");
132-
133-
var expected = GetCurrentUserSettings();
134-
AddOrModifyMockProperties(expected, "mock");
135-
136-
(var setOutput, var setDiff) = Set(new () { Settings = setSettings });
137-
138-
// Assert that the settings are added
139-
Assert.IsNotNull(setOutput);
140-
Assert.AreEqual(setOutput.Action, ActionPropertyValuePartial);
141-
AssertMockProperties(setOutput.Settings, "mock");
142-
AssertSettingsAreEqual(expected, setOutput.Settings);
143-
AssertDiffState(setDiff, [ SettingsPropertyName ]);
144-
}
145-
146-
/// <summary>
147-
/// Calls `set` on the `user-settings-file` resource to update fields.
124+
/// Calls `set` on the `user-settings` resource to update fields.
148125
/// </summary>
149126
/// <param name="action">The action value.</param>
150127
[Test]
@@ -167,14 +144,14 @@ public void UserSettingsFile_Set_UpdateFields(string action)
167144

168145
// Assert that the settings are updated
169146
Assert.IsNotNull(setOutput);
170-
Assert.AreEqual(action, setOutput.Action);
147+
Assert.AreEqual(ActionPropertyValueFull, setOutput.Action);
171148
AssertMockProperties(setOutput.Settings, "mock_new");
172149
AssertSettingsAreEqual(expected, setOutput.Settings);
173150
AssertDiffState(setDiff, [ SettingsPropertyName ]);
174151
}
175152

176153
/// <summary>
177-
/// Calls `test` on the `user-settings-file` resource to check if the settings are in desired state.
154+
/// Calls `test` on the `user-settings` resource to check if the settings are in desired state.
178155
/// </summary>
179156
/// <param name="action">The action value.</param>
180157
[Test]
@@ -197,15 +174,15 @@ public void UserSettingsFile_Test_InDesiredState(string action)
197174

198175
// Assert that the settings are in desired state
199176
Assert.IsNotNull(testOutput);
200-
Assert.AreEqual(action, testOutput.Action);
177+
Assert.AreEqual(ActionPropertyValueFull, testOutput.Action);
201178
AssertMockProperties(testOutput.Settings, "mock");
202179
AssertSettingsAreEqual(expected, testOutput.Settings);
203180
Assert.IsTrue(testOutput.InDesiredState);
204181
AssertDiffState(testDiff, []);
205182
}
206183

207184
/// <summary>
208-
/// Calls `test` on the `user-settings-file` resource to check if the settings are not in desired state.
185+
/// Calls `test` on the `user-settings` resource to check if the settings are not in desired state.
209186
/// </summary>
210187
/// <param name="action">The action value.</param>
211188
[Test]
@@ -228,15 +205,15 @@ public void UserSettingsFile_Test_NotInDesiredState(string action)
228205

229206
// Assert that the settings are not in desired state
230207
Assert.IsNotNull(testOutput);
231-
Assert.AreEqual(action, testOutput.Action);
208+
Assert.AreEqual(ActionPropertyValueFull, testOutput.Action);
232209
AssertMockProperties(testOutput.Settings, "mock_set");
233210
AssertSettingsAreEqual(expected, testOutput.Settings);
234211
Assert.IsFalse(testOutput.InDesiredState);
235212
AssertDiffState(testDiff, [ SettingsPropertyName ]);
236213
}
237214

238215
/// <summary>
239-
/// Calls `export` on the `user-settings-file` resource to export the settings.
216+
/// Calls `export` on the `user-settings` resource to export the settings.
240217
/// </summary>
241218
[Test]
242219
public void UserSettingsFile_Export()
@@ -245,12 +222,12 @@ public void UserSettingsFile_Export()
245222
var exportOutput = Export(new ());
246223

247224
Assert.IsNotNull(exportOutput);
248-
Assert.IsNull(exportOutput.Action);
225+
Assert.AreEqual(ActionPropertyValueFull, exportOutput.Action);
249226
AssertSettingsAreEqual(expected, exportOutput.Settings);
250227
}
251228

252229
/// <summary>
253-
/// Calls `get` on the `user-settings-file` resource.
230+
/// Calls `get` on the `user-settings` resource.
254231
/// </summary>
255232
/// <param name="resourceData">The input resource data.</param>
256233
/// <returns>The output resource data.</returns>
@@ -262,7 +239,7 @@ private static UserSettingsFileResourceData Get(UserSettingsFileResourceData res
262239
}
263240

264241
/// <summary>
265-
/// Calls `set` on the `user-settings-file` resource.
242+
/// Calls `set` on the `user-settings` resource.
266243
/// </summary>
267244
/// <param name="resourceData">The input resource data.</param>
268245
/// <returns>The output resource data and the diff.</returns>
@@ -274,7 +251,7 @@ private static (UserSettingsFileResourceData, List<string>) Set(UserSettingsFile
274251
}
275252

276253
/// <summary>
277-
/// Calls `test` on the `user-settings-file` resource.
254+
/// Calls `test` on the `user-settings` resource.
278255
/// </summary>
279256
/// <param name="resourceData">The input resource data.</param>
280257
/// <returns>The output resource data and the diff.</returns>
@@ -286,7 +263,7 @@ private static (UserSettingsFileResourceData, List<string>) Test(UserSettingsFil
286263
}
287264

288265
/// <summary>
289-
/// Calls `export` on the `user-settings-file` resource.
266+
/// Calls `export` on the `user-settings` resource.
290267
/// </summary>
291268
/// <param name="resourceData">The input resource data.</param>
292269
/// <returns>The output resource data.</returns>
@@ -356,7 +333,6 @@ private class UserSettingsFileResourceData
356333
[JsonPropertyName(InDesiredStatePropertyName)]
357334
public bool? InDesiredState { get; set; }
358335

359-
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
360336
public string Action { get; set; }
361337

362338
public JsonObject Settings { get; set; }

0 commit comments

Comments
 (0)