2022-11-08 20:57:02 +03:00
|
|
|
namespace Sharp.Augeas.Test;
|
|
|
|
|
|
|
|
public class AugeasTests
|
|
|
|
{
|
|
|
|
private Augeas _augeas;
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
public void Setup()
|
|
|
|
{
|
|
|
|
var rootDir = Environment.CurrentDirectory + "/root";
|
|
|
|
var lensDir = Environment.CurrentDirectory + "/lens";
|
|
|
|
_augeas = new Augeas(new AugSettings(rootDir, lensDir));
|
2022-11-12 01:08:45 +03:00
|
|
|
_augeas.LoadFile("/etc/apache2/sites-available/00-ci.codeliturgy.com.conf");
|
|
|
|
_augeas.LoadFile("/etc/apache2/sites-available/02-codeliturgy.com.conf");
|
|
|
|
|
|
|
|
// Load a bunch of files
|
2022-11-08 20:57:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void NoExceptionThrownWhenPrintingVirtualhostTree()
|
|
|
|
{
|
|
|
|
var virtualHostConfig = "/etc/apache2/sites-available/00-ci.codeliturgy.com.conf";
|
|
|
|
_augeas.PrintVirtualHostTree(virtualHostConfig);
|
|
|
|
Assert.Pass();
|
|
|
|
}
|
2022-11-12 01:08:45 +03:00
|
|
|
|
2022-11-08 20:57:02 +03:00
|
|
|
[Test]
|
|
|
|
public void NoExceptionThrownWhenPrintingPreview()
|
|
|
|
{
|
|
|
|
var virtualHostConfig = "/etc/apache2/sites-available/00-ci.codeliturgy.com.conf";
|
|
|
|
_augeas.PrintPreview(virtualHostConfig);
|
|
|
|
Assert.Pass();
|
|
|
|
|
|
|
|
}
|
2022-11-12 01:08:45 +03:00
|
|
|
|
2022-11-08 23:42:09 +03:00
|
|
|
[Test]
|
|
|
|
public void GetPreviewReturnsValid()
|
|
|
|
{
|
2022-11-12 01:08:45 +03:00
|
|
|
|
|
|
|
var preview = _augeas.GetPreview("/files/etc/apache2/sites-available/00-ci.codeliturgy.com.conf");
|
2022-11-08 23:42:09 +03:00
|
|
|
var stringInvalid = string.IsNullOrEmpty(preview);
|
|
|
|
Assert.That(!stringInvalid);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-12 01:08:45 +03:00
|
|
|
|
2022-11-08 20:57:02 +03:00
|
|
|
[Test]
|
2022-11-12 01:08:45 +03:00
|
|
|
public void MatchReturnsTwoSites()
|
2022-11-08 20:57:02 +03:00
|
|
|
{
|
2022-11-12 01:08:45 +03:00
|
|
|
var sites = _augeas.Match("/files/etc/apache2/sites-available/*");
|
|
|
|
Assert.That(sites.Length == 2);
|
2022-11-08 20:57:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-12 01:08:45 +03:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void GetTreeVirtualHostReturnsDictionaryWithKeys()
|
|
|
|
{
|
|
|
|
var path = "/etc/apache2/sites-available/00-ci.codeliturgy.com.conf";
|
|
|
|
var tree = _augeas.GetVirtualHostTree(path);
|
|
|
|
Assert.That(tree.Count > 0);
|
|
|
|
}
|
|
|
|
|
2022-11-08 20:57:02 +03:00
|
|
|
}
|