From 8a63f6ae375d760045238c1195a9c407065b154c Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 24 Sep 2022 19:01:47 -0500 Subject: [PATCH] Fix TagDetails sql for PG, add test --- src/NzbDrone.Core/Movies/MovieRepository.cs | 2 +- .../ApiTests/TagFixture.cs | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 src/NzbDrone.Integration.Test/ApiTests/TagFixture.cs diff --git a/src/NzbDrone.Core/Movies/MovieRepository.cs b/src/NzbDrone.Core/Movies/MovieRepository.cs index 6b6819e3c..569ebf7f1 100644 --- a/src/NzbDrone.Core/Movies/MovieRepository.cs +++ b/src/NzbDrone.Core/Movies/MovieRepository.cs @@ -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>>(strSql).ToDictionary(x => x.Key, x => x.Value); } } diff --git a/src/NzbDrone.Integration.Test/ApiTests/TagFixture.cs b/src/NzbDrone.Integration.Test/ApiTests/TagFixture.cs new file mode 100644 index 000000000..15fc061cb --- /dev/null +++ b/src/NzbDrone.Integration.Test/ApiTests/TagFixture.cs @@ -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); + } + } +}