mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
Fix migration 178 to cope with leading/trailing slashes
This commit is contained in:
parent
7722c50603
commit
85fda91604
@ -35,12 +35,13 @@ public void Setup()
|
|||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("https://api.radarr.video/v2")]
|
[TestCase("https://api.radarr.video/v2")]
|
||||||
|
[TestCase("https://api.radarr.video/v2/")]
|
||||||
[TestCase("https://staging.api.radarr.video")]
|
[TestCase("https://staging.api.radarr.video")]
|
||||||
public void should_switch_some_radarr_to_imdb(string url)
|
public void should_switch_some_radarr_to_imdb(string url)
|
||||||
{
|
{
|
||||||
var db = WithMigrationTestDb(c =>
|
var db = WithMigrationTestDb(c =>
|
||||||
{
|
{
|
||||||
var rows = Builder<new_list_server.NetImportDefinition178>.CreateListOfSize(6)
|
var rows = Builder<new_list_server.NetImportDefinition178>.CreateListOfSize(7)
|
||||||
.All()
|
.All()
|
||||||
.With(x => x.Implementation = typeof(RadarrListImport).Name)
|
.With(x => x.Implementation = typeof(RadarrListImport).Name)
|
||||||
.With(x => x.ConfigContract = typeof(RadarrListSettings).Name)
|
.With(x => x.ConfigContract = typeof(RadarrListSettings).Name)
|
||||||
@ -80,6 +81,12 @@ public void should_switch_some_radarr_to_imdb(string url)
|
|||||||
APIURL = url,
|
APIURL = url,
|
||||||
Path = "/imdb/list?listId=ur002"
|
Path = "/imdb/list?listId=ur002"
|
||||||
}, _serializerSettings))
|
}, _serializerSettings))
|
||||||
|
.TheNext(1)
|
||||||
|
.With(x => x.Settings = JsonSerializer.Serialize(new new_list_server.RadarrListSettings177
|
||||||
|
{
|
||||||
|
APIURL = url,
|
||||||
|
Path = "/imdb/list?listId=ur002/"
|
||||||
|
}, _serializerSettings))
|
||||||
.BuildListOfNew();
|
.BuildListOfNew();
|
||||||
|
|
||||||
var i = 1;
|
var i = 1;
|
||||||
@ -92,14 +99,15 @@ public void should_switch_some_radarr_to_imdb(string url)
|
|||||||
|
|
||||||
var items = db.Query<new_list_server.NetImportDefinition178>("SELECT * FROM NetImport");
|
var items = db.Query<new_list_server.NetImportDefinition178>("SELECT * FROM NetImport");
|
||||||
|
|
||||||
items.Should().HaveCount(6);
|
items.Should().HaveCount(7);
|
||||||
|
|
||||||
VerifyRow(items[0], typeof(IMDbListImport).Name, typeof(IMDbListSettings).Name, new IMDbListSettings { ListId = "top250" });
|
VerifyRow(items[0], typeof(IMDbListImport).Name, typeof(IMDbListSettings).Name, new IMDbListSettings { ListId = "top250" });
|
||||||
VerifyRow(items[1], typeof(IMDbListImport).Name, typeof(IMDbListSettings).Name, new IMDbListSettings { ListId = "popular" });
|
VerifyRow(items[1], typeof(IMDbListImport).Name, typeof(IMDbListSettings).Name, new IMDbListSettings { ListId = "popular" });
|
||||||
VerifyRow(items[2], typeof(RadarrListImport).Name, typeof(RadarrListSettings).Name, new RadarrListSettings { Url = url + "/imdb/missing" });
|
VerifyRow(items[2], typeof(RadarrListImport).Name, typeof(RadarrListSettings).Name, new RadarrListSettings { Url = url.TrimEnd('/') + "/imdb/missing" });
|
||||||
VerifyRow(items[3], typeof(IMDbListImport).Name, typeof(IMDbListSettings).Name, new IMDbListSettings { ListId = "ls001" });
|
VerifyRow(items[3], typeof(IMDbListImport).Name, typeof(IMDbListSettings).Name, new IMDbListSettings { ListId = "ls001" });
|
||||||
VerifyRow(items[4], typeof(RadarrListImport).Name, typeof(RadarrListSettings).Name, new RadarrListSettings { Url = url + "/imdb/list?listId=ls00ad" });
|
VerifyRow(items[4], typeof(RadarrListImport).Name, typeof(RadarrListSettings).Name, new RadarrListSettings { Url = url.TrimEnd('/') + "/imdb/list?listId=ls00ad" });
|
||||||
VerifyRow(items[5], typeof(IMDbListImport).Name, typeof(IMDbListSettings).Name, new IMDbListSettings { ListId = "ur002" });
|
VerifyRow(items[5], typeof(IMDbListImport).Name, typeof(IMDbListSettings).Name, new IMDbListSettings { ListId = "ur002" });
|
||||||
|
VerifyRow(items[6], typeof(IMDbListImport).Name, typeof(IMDbListSettings).Name, new IMDbListSettings { ListId = "ur002" });
|
||||||
}
|
}
|
||||||
|
|
||||||
public void should_switch_some_stevenlu_stevenlu2()
|
public void should_switch_some_stevenlu_stevenlu2()
|
||||||
|
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Datastore.Migration
|
|||||||
[Migration(178)]
|
[Migration(178)]
|
||||||
public class new_list_server : NzbDroneMigrationBase
|
public class new_list_server : NzbDroneMigrationBase
|
||||||
{
|
{
|
||||||
private static readonly Regex ImdbIdRegex = new Regex(@"^/?imdb/list\?listId=(?<id>(ls|ur)\d+)$",
|
private static readonly Regex ImdbIdRegex = new Regex(@"^/*?imdb/list\?listId=(?<id>(ls|ur)\d+)/*?$",
|
||||||
RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||||
private readonly JsonSerializerOptions _serializerSettings;
|
private readonly JsonSerializerOptions _serializerSettings;
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ private void FixRadarrLists(IDbConnection conn, IDbTransaction tran)
|
|||||||
var settings = JsonSerializer.Deserialize<RadarrListSettings177>(row.Settings, _serializerSettings);
|
var settings = JsonSerializer.Deserialize<RadarrListSettings177>(row.Settings, _serializerSettings);
|
||||||
object newSettings;
|
object newSettings;
|
||||||
|
|
||||||
if (!radarrUrls.Contains(settings.APIURL))
|
if (!radarrUrls.Contains(settings.APIURL.TrimEnd('/')))
|
||||||
{
|
{
|
||||||
// Combine root and path in new settings
|
// Combine root and path in new settings
|
||||||
newSettings = new RadarrListSettings178
|
newSettings = new RadarrListSettings178
|
||||||
|
Loading…
Reference in New Issue
Block a user