Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Address timestamps in unit tests #103

Merged
merged 3 commits into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CyLRTests/TestCollectionPaths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public void TestCustomCollectionPaths(){
var userProfile = Environment.ExpandEnvironmentVariables("%HOME%");
var logger = new CyLR.Logger();
logger.LoggingOptions["output_file_path"] = "1.log";
logger.LoggingOptions["output_console_min_level"] = "error";
logger.Setup();

// Set platform specific variables.
Expand Down Expand Up @@ -69,6 +70,7 @@ public void TestCustomCollectionPathsRegExFail(){
var userProfile = Environment.ExpandEnvironmentVariables("%HOME%");
var logger = new CyLR.Logger();
logger.LoggingOptions["output_file_path"] = "2.log";
logger.LoggingOptions["output_console_min_level"] = "error";
logger.Setup();

if (!Platform.IsUnixLike())
Expand Down Expand Up @@ -112,6 +114,7 @@ public void TestCustomCollectionPathsForced(){
var userProfile = Environment.ExpandEnvironmentVariables("%HOME%");
var logger = new CyLR.Logger();
logger.LoggingOptions["output_file_path"] = "3.log";
logger.LoggingOptions["output_console_min_level"] = "error";
logger.Setup();

if (!Platform.IsUnixLike())
Expand Down Expand Up @@ -141,6 +144,7 @@ public void TestCustomCollectionPathsNoFormatType(){
var userProfile = Environment.ExpandEnvironmentVariables("%HOME%");
var logger = new CyLR.Logger();
logger.LoggingOptions["output_file_path"] = "4.log";
logger.LoggingOptions["output_console_min_level"] = "error";
logger.Setup();

if (!Platform.IsUnixLike())
Expand Down
50 changes: 25 additions & 25 deletions CyLRTests/TestLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,62 +74,62 @@ public void TestLoggerFormats(){
logger.Setup();

logger.logger(CyLR.Logger.Level.warn, "This is a warning!");
var now = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss");
var expected = $"{now} [warn] This is a warning!\n";
var expected = "[warn] This is a warning!\n";
var actual = logger.logMessages.Split(" ", 2)[1];

Assert.Equal(expected, logger.logMessages);
Assert.Equal(expected, actual);

logger.TearDown();
}

[Fact]
public void TestLoggerLevelMessages(){
var logger = new CyLR.Logger();
var now = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss");
string expected;
string actual;

logger.Setup();

logger.trace("This is a trace!");
now = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss");
expected = $"{now} [trace] This is a trace!\n";
Assert.Equal(expected, logger.logMessages);
expected = "[trace] This is a trace!\n";
actual = logger.logMessages.Split(" ", 2)[1];
Assert.Equal(expected, actual);
logger.logMessages = "";

logger.debug("This is a debug!");
now = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss");
expected = $"{now} [debug] This is a debug!\n";
Assert.Equal(expected, logger.logMessages);
expected = "[debug] This is a debug!\n";
actual = logger.logMessages.Split(" ", 2)[1];
Assert.Equal(expected, actual);
logger.logMessages = "";

logger.info("This is a info!");
now = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss");
expected = $"{now} [info] This is a info!\n";
Assert.Equal(expected, logger.logMessages);
expected = "[info] This is a info!\n";
actual = logger.logMessages.Split(" ", 2)[1];
Assert.Equal(expected, actual);
logger.logMessages = "";

logger.warn("This is a warning!");
now = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss");
expected = $"{now} [warn] This is a warning!\n";
Assert.Equal(expected, logger.logMessages);
expected = "[warn] This is a warning!\n";
actual = logger.logMessages.Split(" ", 2)[1];
Assert.Equal(expected, actual);
logger.logMessages = "";

logger.error("This is a error!");
now = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss");
expected = $"{now} [error] This is a error!\n";
Assert.Equal(expected, logger.logMessages);
expected = "[error] This is a error!\n";
actual = logger.logMessages.Split(" ", 2)[1];
Assert.Equal(expected, actual);
logger.logMessages = "";

logger.critical("This is a critical!");
now = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss");
expected = $"{now} [critical] This is a critical!\n";
Assert.Equal(expected, logger.logMessages);
expected = "[critical] This is a critical!\n";
actual = logger.logMessages.Split(" ", 2)[1];
Assert.Equal(expected, actual);
logger.logMessages = "";

logger.none("This is a none!");
now = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss");
expected = $"{now} [none] This is a none!\n";
Assert.Equal(expected, logger.logMessages);
expected = "[none] This is a none!\n";
actual = logger.logMessages.Split(" ", 2)[1];
Assert.Equal(expected, actual);

logger.TearDown();
}
Expand Down
8 changes: 2 additions & 6 deletions scripts/package.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
BUILD_DIR="." && [[ "$TRAVIS_BUILD_DIR" != "" ]] && BUILD_DIR=$TRAVIS_BUILD_DIR

$ZIP_COMMAND="zip"

unameOut="$(uname -s)"

case "${unameOut}" in
Expand All @@ -17,12 +19,6 @@ if [ ! -d $BUILD_DIR/deployments/CyLR/$BUILD_ARCH ]; then
mkdir -p $BUILD_DIR/deployments/CyLR/$BUILD_ARCH
fi

if [ ! -f "./warp-packer" ] ; then

curl -Lo warp-packer "https://github.com/dgiagio/warp/releases/download/v0.3.0/$PACKER_ARCH.warp-packer"
chmod +x warp-packer
fi

cp -r $BUILD_DIR/CyLR/bin/Release/netcoreapp3.1/$BUILD_ARCH/publish/ $BUILD_DIR/deployments/CyLR

echo "Zipping files:"
Expand Down