mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02: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:
@@ -69,7 +69,9 @@ namespace Jackett.Common.Services
|
|||||||
{
|
{
|
||||||
try
|
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
|
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()
|
public string GetContentFolder()
|
||||||
{
|
{
|
||||||
|
@@ -51,7 +51,9 @@ namespace Jackett.Common.Services
|
|||||||
}
|
}
|
||||||
else
|
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);
|
var exePath = Path.Combine(applicationFolder, SERVICEEXE);
|
||||||
if (!File.Exists(exePath) && Debugger.IsAttached)
|
if (!File.Exists(exePath) && Debugger.IsAttached)
|
||||||
|
@@ -47,7 +47,9 @@ namespace Jackett.Server.Services
|
|||||||
}
|
}
|
||||||
else
|
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);
|
var exePath = Path.Combine(applicationFolder, SERVICEEXE);
|
||||||
if (!File.Exists(exePath) && Debugger.IsAttached)
|
if (!File.Exists(exePath) && Debugger.IsAttached)
|
||||||
|
@@ -51,7 +51,9 @@ namespace Jackett.Service
|
|||||||
|
|
||||||
private void StartConsoleApplication()
|
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");
|
var exePath = Path.Combine(applicationFolder, "JackettConsole.exe");
|
||||||
|
|
||||||
|
38
src/Jackett.Test/Definitions/DefinitionsParserTests.cs
Normal file
38
src/Jackett.Test/Definitions/DefinitionsParserTests.cs
Normal 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}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user