Fixed: Updated BTN api url.

pull/1707/head
Taloth Saldono 8 years ago
parent 9304547c95
commit 060b9f6fd1

@ -0,0 +1,62 @@
using System.Linq;
using FluentAssertions;
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 update_btn_url_migration_fixture : MigrationTest<update_btn_url>
{
[TestCase("http://api.btnapps.net")]
[TestCase("https://api.btnapps.net")]
[TestCase("http://api.btnapps.net/")]
[TestCase("https://api.btnapps.net/")]
public void should_replace_old_url(string oldUrl)
{
var db = WithMigrationTestDb(c =>
{
c.Insert.IntoTable("Indexers").Row(new
{
Name = "btn_old_url",
Implementation = "BroadcastheNet",
Settings = new BroadcastheNetSettings106
{
BaseUrl = oldUrl
}.ToJson(),
ConfigContract = "BroadcastheNetSettings"
});
});
var items = db.Query<IndexerDefinition90>("SELECT * FROM Indexers");
items.Should().HaveCount(1);
items.First().Settings.ToObject<BroadcastheNetSettings106>().BaseUrl.Should().Contain("api.broadcasthe.net");
}
[Test]
public void should_not_replace_other_indexers()
{
var db = WithMigrationTestDb(c =>
{
c.Insert.IntoTable("Indexers").Row(new
{
Name = "not_btn",
Implementation = "NotBroadcastheNet",
Settings = new BroadcastheNetSettings106
{
BaseUrl = "http://api.btnapps.net",
}.ToJson(),
ConfigContract = "BroadcastheNetSettings"
});
});
var items = db.Query<IndexerDefinition90>("SELECT * FROM Indexers");
items.Should().HaveCount(1);
items.First().Settings.ToObject<BroadcastheNetSettings106>().BaseUrl.Should().Be("http://api.btnapps.net");
}
}
}

@ -21,7 +21,7 @@ namespace NzbDrone.Core.Test.IndexerTests.BroadcastheNetTests
Subject.Definition = new IndexerDefinition()
{
Name = "BroadcastheNet",
Settings = new BroadcastheNetSettings() { ApiKey = "abc", BaseUrl = "https://api.btnapps.net/" }
Settings = new BroadcastheNetSettings() { ApiKey = "abc", BaseUrl = "https://api.broadcasthe.net/" }
};
}
@ -139,7 +139,7 @@ namespace NzbDrone.Core.Test.IndexerTests.BroadcastheNetTests
{
var recentFeed = ReadAllText(@"Files/Indexers/BroadcastheNet/RecentFeed.json");
(Subject.Definition.Settings as BroadcastheNetSettings).BaseUrl = "http://api.btnapps.net/";
(Subject.Definition.Settings as BroadcastheNetSettings).BaseUrl = "http://api.broadcasthe.net/";
recentFeed = recentFeed.Replace("http:", "https:");

@ -124,6 +124,7 @@
<Compile Include="Datastore\DatabaseRelationshipFixture.cs" />
<Compile Include="Datastore\MappingExtentionFixture.cs" />
<Compile Include="Datastore\MarrDataLazyLoadingFixture.cs" />
<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\101_add_ultrahd_quality_in_profilesFixture.cs" />

@ -0,0 +1,22 @@
using FluentMigrator;
using Newtonsoft.Json.Linq;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(106)]
public class update_btn_url : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Execute.Sql("UPDATE Indexers SET Settings = Replace(Settings, 'api.btnapps.net', 'api.broadcasthe.net') WHERE Implementation = 'BroadcastheNet';");
}
}
public class BroadcastheNetSettings106
{
public string BaseUrl { get; set; }
public string ApiKey { get; set; }
}
}

@ -20,7 +20,7 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet
public BroadcastheNetSettings()
{
BaseUrl = "http://api.btnapps.net/";
BaseUrl = "http://api.broadcasthe.net/";
}
[FieldDefinition(0, Label = "API URL", Advanced = true, HelpText = "Do not change this unless you know what you're doing. Since your API key will be sent to that host.")]
@ -34,4 +34,4 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet
return new NzbDroneValidationResult(Validator.Validate(this));
}
}
}
}

@ -249,6 +249,7 @@
<Compile Include="Datastore\Migration\068_add_release_restrictions.cs" />
<Compile Include="Datastore\Migration\069_quality_proper.cs" />
<Compile Include="Datastore\Migration\070_delay_profile.cs" />
<Compile Include="Datastore\Migration\106_update_btn_url.cs" />
<Compile Include="Datastore\Migration\096_disable_kickass.cs" />
<Compile Include="Datastore\Migration\095_add_additional_episodes_index.cs" />
<Compile Include="Datastore\Migration\104_remove_kickass.cs" />

Loading…
Cancel
Save