move linux config path to /opt/epson-print-service

This commit is contained in:
EugeneTes
2026-07-23 08:16:23 +00:00
parent 120634e569
commit 7dfce95dc1
2 changed files with 41 additions and 1 deletions

View File

@@ -4,7 +4,7 @@ namespace EpsonPrintService;
public static class ConfigurationPaths
{
private const string LinuxConfigDir = "/root/epsonprintservice";
private const string LinuxConfigDir = "/opt/epson-print-service";
private const string LocalConfigFileName = "config.txt";
public static string GetConfigPath()

View File

@@ -0,0 +1,40 @@
using System.Runtime.InteropServices;
using EpsonPrintService;
namespace Inspectron.Epson.Tests.Configuration;
public class ConfigurationPathsTests
{
[Fact]
public void GetConfigPath_uses_opt_dir_on_linux_when_env_unset_and_no_local_file()
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) return;
var previous = Environment.GetEnvironmentVariable("EPSON_CONFIG_PATH");
Environment.SetEnvironmentVariable("EPSON_CONFIG_PATH", null);
try
{
var path = ConfigurationPaths.GetConfigPath();
Assert.Equal("/opt/epson-print-service/config.txt", path);
}
finally
{
Environment.SetEnvironmentVariable("EPSON_CONFIG_PATH", previous);
}
}
[Fact]
public void EPSON_CONFIG_PATH_override_still_wins()
{
var previous = Environment.GetEnvironmentVariable("EPSON_CONFIG_PATH");
Environment.SetEnvironmentVariable("EPSON_CONFIG_PATH", "/tmp/override.txt");
try
{
var path = ConfigurationPaths.GetConfigPath();
Assert.Equal("/tmp/override.txt", path);
}
finally
{
Environment.SetEnvironmentVariable("EPSON_CONFIG_PATH", previous);
}
}
}