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

Don't assume string params to Install are identifiers #2764

Merged
merged 2 commits into from
May 21, 2019
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
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