65 lines
1.7 KiB
C#
65 lines
1.7 KiB
C#
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));
|
|
_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
|
|
}
|
|
|
|
[Test]
|
|
public void NoExceptionThrownWhenPrintingVirtualhostTree()
|
|
{
|
|
var virtualHostConfig = "/etc/apache2/sites-available/00-ci.codeliturgy.com.conf";
|
|
_augeas.PrintVirtualHostTree(virtualHostConfig);
|
|
Assert.Pass();
|
|
}
|
|
|
|
[Test]
|
|
public void NoExceptionThrownWhenPrintingPreview()
|
|
{
|
|
var virtualHostConfig = "/etc/apache2/sites-available/00-ci.codeliturgy.com.conf";
|
|
_augeas.PrintPreview(virtualHostConfig);
|
|
Assert.Pass();
|
|
|
|
}
|
|
|
|
[Test]
|
|
public void GetPreviewReturnsValid()
|
|
{
|
|
|
|
var preview = _augeas.GetPreview("/files/etc/apache2/sites-available/00-ci.codeliturgy.com.conf");
|
|
var stringInvalid = string.IsNullOrEmpty(preview);
|
|
Assert.That(!stringInvalid);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
public void MatchReturnsTwoSites()
|
|
{
|
|
var sites = _augeas.Match("/files/etc/apache2/sites-available/*");
|
|
Assert.That(sites.Length == 2);
|
|
}
|
|
|
|
|
|
|
|
[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);
|
|
}
|
|
|
|
} |