Skip to content

Commit

Permalink
Added missing migration test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Taloth committed May 30, 2019
1 parent f3435f9 commit cce59fa
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 1 deletion.
@@ -0,0 +1,129 @@
using System.Linq;
using FluentAssertions;
using Newtonsoft.Json.Linq;
using NUnit.Framework;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.Datastore.Migration;
using NzbDrone.Core.Test.Framework;

namespace NzbDrone.Core.Test.Datastore.Migration
{
[TestFixture]
public class add_download_client_priorityFixture : MigrationTest<add_download_client_priority>
{
[Test]
public void should_set_prio_to_one()
{
var db = WithMigrationTestDb(c =>
{
c.Insert.IntoTable("DownloadClients").Row(new
{
Enable = 1,
Name = "Deluge",
Implementation = "Deluge",
Settings = new DelugeSettings85
{
Host = "127.0.0.1",
TvCategory = "abc",
UrlBase = "/my/"
}.ToJson(),
ConfigContract = "DelugeSettings"
});
});

var items = db.Query<DownloadClientDefinition132>("SELECT * FROM DownloadClients");

items.Should().HaveCount(1);
items.First().Priority.Should().Be(1);
}

[Test]
public void should_renumber_prio_for_enabled_clients()
{
var db = WithMigrationTestDb(c =>
{
c.Insert.IntoTable("DownloadClients").Row(new
{
Enable = 1,
Name = "Deluge",
Implementation = "Deluge",
Settings = new DelugeSettings85
{
Host = "127.0.0.1",
TvCategory = "abc",
UrlBase = "/my/"
}.ToJson(),
ConfigContract = "DelugeSettings"
}).Row(new
{
Enable = 1,
Name = "Deluge2",
Implementation = "Deluge",
Settings = new DelugeSettings85
{
Host = "127.0.0.1",
TvCategory = "abc",
UrlBase = "/my/"
}.ToJson(),
ConfigContract = "DelugeSettings"
});
});

var items = db.Query<DownloadClientDefinition132>("SELECT * FROM DownloadClients");

items.Should().HaveCount(2);
items[0].Priority.Should().Be(1);
items[1].Priority.Should().Be(2);
}

[Test]
public void should_not_renumber_prio_for_disabled_clients()
{
var db = WithMigrationTestDb(c =>
{
c.Insert.IntoTable("DownloadClients").Row(new
{
Enable = 0,
Name = "Deluge",
Implementation = "Deluge",
Settings = new DelugeSettings85
{
Host = "127.0.0.1",
TvCategory = "abc",
UrlBase = "/my/"
}.ToJson(),
ConfigContract = "DelugeSettings"
}).Row(new
{
Enable = 0,
Name = "Deluge2",
Implementation = "Deluge",
Settings = new DelugeSettings85
{
Host = "127.0.0.1",
TvCategory = "abc",
UrlBase = "/my/"
}.ToJson(),
ConfigContract = "DelugeSettings"
});
});

var items = db.Query<DownloadClientDefinition132>("SELECT * FROM DownloadClients");

items.Should().HaveCount(2);
items[0].Priority.Should().Be(1);
items[1].Priority.Should().Be(1);
}
}

public class DownloadClientDefinition132
{
public int Id { get; set; }
public bool Enable { get; set; }
public int Priority { get; set; }
public string Name { get; set; }
public string Implementation { get; set; }
public JObject Settings { get; set; }
public string ConfigContract { get; set; }
}
}
3 changes: 2 additions & 1 deletion src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
Expand Up @@ -139,7 +139,8 @@
<Compile Include="Datastore\Migration\106_update_btn_urlFixture.cs" />
<Compile Include="Datastore\Migration\103_fix_metadata_file_extensionsFixture.cs" />
<Compile Include="Datastore\Migration\099_extra_and_subtitle_filesFixture.cs" />
<Compile Include="Datastore\Migration\122_add_remux_qualities_in_profile.cs" />
<Compile Include="Datastore\Migration\132_add_download_client_priorityFixture.cs" />
<Compile Include="Datastore\Migration\122_add_remux_qualities_in_profileFixture.cs" />
<Compile Include="Datastore\Migration\071_unknown_quality_in_profileFixture.cs" />
<Compile Include="Datastore\Migration\072_history_downloadIdFixture.cs" />
<Compile Include="Datastore\Migration\070_delay_profileFixture.cs" />
Expand Down

0 comments on commit cce59fa

Please sign in to comment.