Fix TagDetails sql for PG, add test

This commit is contained in:
Qstick 2022-09-24 19:01:47 -05:00
parent 069b18e5e3
commit 8a63f6ae37
2 changed files with 54 additions and 1 deletions

View File

@ -311,7 +311,7 @@ namespace NzbDrone.Core.Movies
{
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);
}
}

View File

@ -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);
}
}
}