Skip to content

Commit

Permalink
Merge #2764 Don't assume string params to Install are identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed May 21, 2019
2 parents 8eabff4 + c579ac1 commit 19f7302
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
- [Core] Cache downloads individually upon completion (#2756 by: HebaruSan; reviewed: DasSkelett)
- [GUI] Hide auto-installed checkbox for auto-detected mods (#2758 by: HebaruSan; reviewed: DasSkelett)
- [GUI] Update GUI modlist if scan detects changes (#2762 by: HebaruSan; reviewed: DasSkelett)
- [Core] Don't assume string params to Install are identifiers (#2764 by: HebaruSan; reviewed: DasSkelett)

## v1.26.2

Expand Down
2 changes: 1 addition & 1 deletion Core/ModuleInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void InstallList(List<string> modules, RelationshipResolverOptions option
{
var resolver = new RelationshipResolver(modules, null, options, registry_manager.registry, ksp.VersionCriteria());
// Only pass the CkanModules of the parameters, so we can tell which are auto
InstallList(resolver.ModList().Where(m => modules.Contains(m.identifier)).ToList(), options, downloader);
InstallList(resolver.ModList().Where(m => resolver.ReasonFor(m) is SelectionReason.UserRequested).ToList(), options, downloader);
}

/// <summary>
Expand Down
35 changes: 35 additions & 0 deletions Tests/Core/ModuleInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,41 @@ public void CanInstallMod()
}
}

[Test]
public void InstallList_IdentifierEqualsVersionSyntax_InstallsModule()
{
using (DisposableKSP ksp = new DisposableKSP())
{
// Arrange
KSPManager manager = new KSPManager(
new NullUser(),
new FakeWin32Registry(ksp.KSP, ksp.KSP.Name)
) {
CurrentInstance = ksp.KSP
};
var registry = CKAN.RegistryManager.Instance(ksp.KSP).registry;
var inst = CKAN.ModuleInstaller.GetInstance(ksp.KSP, manager.Cache, nullUser);

const string mod_file_name = "DogeCoinFlag/Flags/dogecoin.png";
string mod_file_path = Path.Combine(ksp.KSP.GameData(), mod_file_name);
CkanModule mod = TestData.DogeCoinFlag_101_module();
registry.AddAvailable(mod);
manager.Cache.Store(mod, TestData.DogeCoinFlagZip());
List<string> modules = new List<string>()
{
$"{mod.identifier}={mod.version}"
};

// Act
inst.InstallList(modules, new RelationshipResolverOptions());

// Assert
Assert.IsTrue(File.Exists(mod_file_path));

manager.Dispose();
}
}

[Test]
public void CanUninstallMod()
{
Expand Down

0 comments on commit 19f7302

Please sign in to comment.