1
0
Fork 0
mirror of https://github.com/Jackett/Jackett synced 2024-12-29 11:17:22 +00:00

test: add unit test to validate all cardigann definitions (#8165)

* test: add unit test to validate all cardigann definitions

Error while parsing Cardigann definition 4thd.yml
YamlDotNet.Core.YamlException: (Line: 13, Col: 9, Idx: 240) - (Line: 13, Col: 9, Idx: 240): Exception during deserialization
 ---> System.Runtime.Serialization.SerializationException: Property 'dec' not found on type 'Jackett.Common.Models.CategorymappingBlock'.
This commit is contained in:
Diego Heras 2020-04-13 09:34:45 +02:00 committed by GitHub
parent 1cbc19823d
commit 47454e4c1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 6 deletions

View file

@ -69,7 +69,9 @@ namespace Jackett.Common.Services
{
try
{
processService.StartProcessAndLog(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath, "--MigrateSettings", true);
// Use EscapedCodeBase to avoid Uri reserved characters from causing bugs
// https://stackoverflow.com/questions/896572
processService.StartProcessAndLog(new Uri(Assembly.GetExecutingAssembly().EscapedCodeBase).LocalPath, "--MigrateSettings", true);
}
catch
{
@ -164,7 +166,9 @@ namespace Jackett.Common.Services
}
}
public string ApplicationFolder() => Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
// Use EscapedCodeBase to avoid Uri reserved characters from causing bugs
// https://stackoverflow.com/questions/896572
public string ApplicationFolder() => Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().EscapedCodeBase).LocalPath);
public string GetContentFolder()
{
@ -232,7 +236,7 @@ namespace Jackett.Common.Services
}
else
{
//We don't load these out of the config files as it could get confusing to users who accidently save.
//We don't load these out of the config files as it could get confusing to users who accidently save.
//In future we could flatten the serverconfig, and use command line parameters to override any configuration.
config.RuntimeSettings = runtimeSettings;
}

View file

@ -51,7 +51,9 @@ namespace Jackett.Common.Services
}
else
{
var applicationFolder = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
// Use EscapedCodeBase to avoid Uri reserved characters from causing bugs
// https://stackoverflow.com/questions/896572
var applicationFolder = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().EscapedCodeBase).LocalPath);
var exePath = Path.Combine(applicationFolder, SERVICEEXE);
if (!File.Exists(exePath) && Debugger.IsAttached)

View file

@ -47,7 +47,9 @@ namespace Jackett.Server.Services
}
else
{
var applicationFolder = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
// Use EscapedCodeBase to avoid Uri reserved characters from causing bugs
// https://stackoverflow.com/questions/896572
var applicationFolder = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().EscapedCodeBase).LocalPath);
var exePath = Path.Combine(applicationFolder, SERVICEEXE);
if (!File.Exists(exePath) && Debugger.IsAttached)

View file

@ -51,7 +51,9 @@ namespace Jackett.Service
private void StartConsoleApplication()
{
var applicationFolder = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
// Use EscapedCodeBase to avoid Uri reserved characters from causing bugs
// https://stackoverflow.com/questions/896572
var applicationFolder = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().EscapedCodeBase).LocalPath);
var exePath = Path.Combine(applicationFolder, "JackettConsole.exe");

View file

@ -0,0 +1,38 @@
using System;
using System.IO;
using System.Reflection;
using Jackett.Common.Models;
using NUnit.Framework;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
using Assert = NUnit.Framework.Assert;
namespace Jackett.Test.Definitions
{
[TestFixture]
public class DefinitionsParserTests
{
[Test]
public void LoadAndParseAllCardigannDefinitions()
{
// Use EscapedCodeBase to avoid Uri reserved characters from causing bugs
// https://stackoverflow.com/questions/896572
var applicationFolder = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().EscapedCodeBase).LocalPath);
var definitionsFolder = Path.GetFullPath(Path.Combine(applicationFolder, "Definitions"));
var deserializer = new DeserializerBuilder()
.WithNamingConvention(CamelCaseNamingConvention.Instance)
.Build();
var files = new DirectoryInfo(definitionsFolder).GetFiles("*.yml");
foreach (var file in files)
try
{
var definitionString = File.ReadAllText(file.FullName);
deserializer.Deserialize<IndexerDefinition>(definitionString);
}
catch (Exception ex)
{
Assert.Fail($"Error while parsing Cardigann definition {file.Name}\n{ex}");
}
}
}
}