-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1946 from Nexus-Mods/feat/synchronizer-tests
Add test for #1924 fix: ingesting changes to existing files
- Loading branch information
Showing
3 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
...zer.Tests/GeneralFileManagementTests.SynchronizerFileManagementTest.verified.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
## 1 - Loadout Created (A) - Synced: | ||
Added a new loadout and synced it. | ||
### Initial State - (0) - Tx:100000000000005 | ||
| Path | Hash | Size | TxId | | ||
| --- | --- | --- | --- | | ||
### Last Synced State - (0) - Tx:100000000000008 | ||
| Path | Hash | Size | TxId | | ||
| --- | --- | --- | --- | | ||
### Current State - (0) - Tx:100000000000008 | ||
| Path | Hash | Size | TxId | | ||
| --- | --- | --- | --- | | ||
### Loadout A - (0) | ||
| Path | Hash | Size | TxId | | ||
| --- | --- | --- | --- | | ||
|
||
|
||
|
||
## 2 - Added bin/newFile - Synced: | ||
Added a new file to the game and synced it. | ||
### Initial State - (0) - Tx:100000000000005 | ||
| Path | Hash | Size | TxId | | ||
| --- | --- | --- | --- | | ||
### Last Synced State - (1) - Tx:10000000000000B | ||
| Path | Hash | Size | TxId | | ||
| --- | --- | --- | --- | | ||
| (EId:200000000000001, Game, bin/newFile.txt) | 0xA52B286A3E7F4D91 | 12 B | Tx:10000000000000B | | ||
### Current State - (1) - Tx:10000000000000B | ||
| Path | Hash | Size | TxId | | ||
| --- | --- | --- | --- | | ||
| (EId:200000000000001, Game, bin/newFile.txt) | 0xA52B286A3E7F4D91 | 12 B | Tx:10000000000000B | | ||
### Loadout A - (1) | ||
| Path | Hash | Size | TxId | | ||
| --- | --- | --- | --- | | ||
| (EId:200000000000003, Game, bin/newFile.txt) | 0xA52B286A3E7F4D91 | 12 B | Tx:10000000000000B | | ||
|
||
|
||
|
||
## 2 - Updated the file - Synced: | ||
Updated the new file file and synced it. | ||
### Initial State - (0) - Tx:100000000000005 | ||
| Path | Hash | Size | TxId | | ||
| --- | --- | --- | --- | | ||
### Last Synced State - (1) - Tx:10000000000000E | ||
| Path | Hash | Size | TxId | | ||
| --- | --- | --- | --- | | ||
| (EId:200000000000001, Game, bin/newFile.txt) | 0xCBF180132E60CE25 | 21 B | Tx:10000000000000E | | ||
### Current State - (1) - Tx:10000000000000E | ||
| Path | Hash | Size | TxId | | ||
| --- | --- | --- | --- | | ||
| (EId:200000000000001, Game, bin/newFile.txt) | 0xCBF180132E60CE25 | 21 B | Tx:10000000000000E | | ||
### Loadout A - (1) | ||
| Path | Hash | Size | TxId | | ||
| --- | --- | --- | --- | | ||
| (EId:200000000000003, Game, bin/newFile.txt) | 0xCBF180132E60CE25 | 21 B | Tx:10000000000000E | | ||
|
||
|
||
|
54 changes: 54 additions & 0 deletions
54
tests/NexusMods.DataModel.Synchronizer.Tests/GeneralFileManagementTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System.Text; | ||
using NexusMods.Abstractions.GameLocators; | ||
using NexusMods.Games.TestFramework; | ||
using Xunit.Abstractions; | ||
|
||
namespace NexusMods.DataModel.Synchronizer.Tests; | ||
|
||
public class GeneralFileManagementTests (ITestOutputHelper helper) : ACyberpunkIsolatedGameTest<GeneralModManagementTests>(helper) | ||
{ | ||
[Fact] | ||
public async Task SynchronizerFileManagementTest() | ||
{ | ||
var sb = new StringBuilder(); | ||
|
||
await Synchronizer.RescanGameFiles(GameInstallation); | ||
var loadoutA = await CreateLoadout(false); | ||
loadoutA = await Synchronizer.Synchronize(loadoutA); | ||
await Synchronizer.RescanGameFiles(GameInstallation); | ||
|
||
LogDiskState(sb, "## 1 - Loadout Created (A) - Synced", | ||
""" | ||
Added a new loadout and synced it. | ||
""", [loadoutA]); | ||
|
||
// Add a new file to the game | ||
var newfileGamePath = new GamePath(LocationId.Game, "bin/newFile.txt"); | ||
var newFileFullPath = GameInstallation.LocationsRegister.GetResolvedPath(newfileGamePath); | ||
newFileFullPath.Parent.CreateDirectory(); | ||
await newFileFullPath.WriteAllTextAsync("Hello World!"); | ||
|
||
await Synchronizer.RescanGameFiles(GameInstallation); | ||
loadoutA = await Synchronizer.Synchronize(loadoutA); | ||
await Synchronizer.RescanGameFiles(GameInstallation); | ||
|
||
LogDiskState(sb, "## 2 - Added bin/newFile - Synced", | ||
""" | ||
Added a new file to the game and synced it. | ||
""", [loadoutA]); | ||
|
||
// Update the new file contents | ||
await newFileFullPath.WriteAllTextAsync("Hello World! Updated!"); | ||
|
||
await Synchronizer.RescanGameFiles(GameInstallation); | ||
loadoutA = await Synchronizer.Synchronize(loadoutA); | ||
await Synchronizer.RescanGameFiles(GameInstallation); | ||
|
||
LogDiskState(sb, "## 2 - Updated the file - Synced", | ||
""" | ||
Updated the new file file and synced it. | ||
""", [loadoutA]); | ||
|
||
await Verify(sb.ToString(), extension: "md"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters