mirror of
				https://github.com/Kareadita/Kavita.git
				synced 2025-11-04 03:27:05 -05:00 
			
		
		
		
	* Recreated Kavita Logging with Serilog instead of Default. This needs to be move out of the appsettings now, to allow auto updater to patch. * Refactored the code to be completely configured via Code rather than appsettings.json. This is a required step for Auto Updating. * Added in the ability to send logs directly to the UI only for users on the log route. Stopping implementation as Alerts page will handle the rest of the implementation. * Fixed up the backup service to not rely on Config from appsettings.json * Tweaked the Logging levels available * Moved everything over to File-scoped namespaces * Moved everything over to File-scoped namespaces * Code cleanup, removed an old migration and changed so debug logging doesn't print sensitive db data * Removed dead code
		
			
				
	
	
		
			33 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using System;
 | 
						|
using System.Globalization;
 | 
						|
using System.IO;
 | 
						|
using API.Extensions;
 | 
						|
using Xunit;
 | 
						|
 | 
						|
namespace API.Tests.Extensions;
 | 
						|
 | 
						|
public class FileInfoExtensionsTests
 | 
						|
{
 | 
						|
    private static readonly string TestDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Extensions/Test Data/");
 | 
						|
 | 
						|
    [Fact]
 | 
						|
    public void HasFileBeenModifiedSince_ShouldBeFalse()
 | 
						|
    {
 | 
						|
        var filepath = Path.Join(TestDirectory, "not modified.txt");
 | 
						|
        var date = new FileInfo(filepath).LastWriteTime;
 | 
						|
        Assert.False(new FileInfo(filepath).HasFileBeenModifiedSince(date));
 | 
						|
        File.ReadAllText(filepath);
 | 
						|
        Assert.False(new FileInfo(filepath).HasFileBeenModifiedSince(date));
 | 
						|
    }
 | 
						|
 | 
						|
    [Fact]
 | 
						|
    public void HasFileBeenModifiedSince_ShouldBeTrue()
 | 
						|
    {
 | 
						|
        var filepath = Path.Join(TestDirectory, "modified on run.txt");
 | 
						|
        var date = new FileInfo(filepath).LastWriteTime;
 | 
						|
        Assert.False(new FileInfo(filepath).HasFileBeenModifiedSince(date));
 | 
						|
        File.AppendAllLines(filepath, new[] { DateTime.Now.ToString(CultureInfo.InvariantCulture) });
 | 
						|
        Assert.True(new FileInfo(filepath).HasFileBeenModifiedSince(date));
 | 
						|
    }
 | 
						|
}
 |