mirror of https://github.com/Radarr/Radarr
Fix TagDetails sql for PG, add test
This commit is contained in:
parent
069b18e5e3
commit
8a63f6ae37
|
@ -311,7 +311,7 @@ namespace NzbDrone.Core.Movies
|
||||||
{
|
{
|
||||||
using (var conn = _database.OpenConnection())
|
using (var conn = _database.OpenConnection())
|
||||||
{
|
{
|
||||||
var strSql = "SELECT \"Id\" AS \"Key\", \"Tags\" AS \"Value\" FROM \"Movies\" WHERE \"Value\" IS NOT NULL";
|
var strSql = "SELECT \"Id\" AS \"Key\", \"Tags\" AS \"Value\" FROM \"Movies\" WHERE \"Tags\" IS NOT NULL";
|
||||||
return conn.Query<KeyValuePair<int, List<int>>>(strSql).ToDictionary(x => x.Key, x => x.Value);
|
return conn.Query<KeyValuePair<int, List<int>>>(strSql).ToDictionary(x => x.Key, x => x.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
using System.Linq;
|
||||||
|
using FluentAssertions;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using Radarr.Api.V3.Tags;
|
||||||
|
|
||||||
|
namespace NzbDrone.Integration.Test.ApiTests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TagFixture : IntegrationTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
[Order(0)]
|
||||||
|
public void should_not_have_tags_initially()
|
||||||
|
{
|
||||||
|
EnsureNoTag("test");
|
||||||
|
|
||||||
|
var items = Tags.All().Should().BeEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[Order(2)]
|
||||||
|
public void should_be_able_to_add_tag()
|
||||||
|
{
|
||||||
|
var item = Tags.Post(new TagResource { Label = "test" });
|
||||||
|
|
||||||
|
item.Id.Should().NotBe(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[Order(2)]
|
||||||
|
public void get_all_tags()
|
||||||
|
{
|
||||||
|
EnsureTag("test");
|
||||||
|
|
||||||
|
var clients = Tags.All();
|
||||||
|
|
||||||
|
clients.Should().NotBeNullOrEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[Order(4)]
|
||||||
|
public void delete_tag()
|
||||||
|
{
|
||||||
|
var client = EnsureTag("test");
|
||||||
|
|
||||||
|
Tags.Get(client.Id).Should().NotBeNull();
|
||||||
|
|
||||||
|
Tags.Delete(client.Id);
|
||||||
|
|
||||||
|
Tags.All().Should().NotContain(v => v.Id == client.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue