Skip to content

Commit bcb3bb4

Browse files
authored
Merge pull request #34 from merbla/build-rework
Build rework and cleanup
2 parents 92c6fe1 + 98ab271 commit bcb3bb4

File tree

3 files changed

+46
-7
lines changed

3 files changed

+46
-7
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ addons:
1818
- zlib1g
1919

2020
os:
21-
- osx
21+
#- osx
2222
- linux
2323

2424
env:
2525
matrix:
2626
- CLI_VERSION=1.0.0-preview2-003121
27-
- CLI_VERSION=Latest
27+
# - CLI_VERSION=Latest
2828

2929
matrix:
3030
allow_failures:

build.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
#!/bin/bash
2+
3+
# Ensure any exit code exits TravisCI
4+
set -e
5+
26
dotnet restore
37
for path in src/*/project.json; do
48
dirname="$(dirname "${path}")"
@@ -8,4 +12,10 @@ done
812
for path in sample/project.json; do
913
dirname="$(dirname "${path}")"
1014
dotnet build ${dirname}
11-
done
15+
done
16+
17+
for path in test/Serilog.Sinks.Splunk.Tests/project.json; do
18+
dirname="$(dirname "${path}")"
19+
dotnet build ${dirname} -f netcoreapp1.0 -c Release
20+
dotnet test ${dirname} -f netcoreapp1.0 -c Release
21+
done

test/Serilog.Sinks.Splunk.Tests/SplunkJsonFormatterTests.cs

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@ namespace Serilog.Sinks.Splunk.Tests
88
{
99
public class SplunkJsonFormatterTests
1010
{
11-
void AssertValidJson(Action<ILogger> act)
11+
void AssertValidJson(Action<ILogger> act,
12+
string source = "",
13+
string sourceType= "",
14+
string host= "",
15+
string index= "")
1216
{
1317
StringWriter outputRendered = new StringWriter(), output = new StringWriter();
1418
var log = new LoggerConfiguration()
15-
.WriteTo.Sink(new TextWriterSink(output, new SplunkJsonFormatter(false, null)))
16-
.WriteTo.Sink(new TextWriterSink(outputRendered, new SplunkJsonFormatter(true, null)))
19+
.WriteTo.Sink(new TextWriterSink(output, new SplunkJsonFormatter(false, null, source, sourceType, host, index)))
20+
.WriteTo.Sink(new TextWriterSink(outputRendered, new SplunkJsonFormatter(true, null, source, sourceType, host, index)))
1721
.CreateLogger();
1822

1923
act(log);
@@ -52,5 +56,30 @@ public void ExceptionAndPropertiesAreValidJson()
5256
{
5357
AssertValidJson(log => log.Information(new DivideByZeroException(), "With exception and {Property}", 42));
5458
}
59+
60+
[Fact]
61+
public void AMinimalEventWithSourceIsValidJson()
62+
{
63+
AssertValidJson(log => log.Information("One {Property}", 42), source: "A Test Source");
64+
}
65+
66+
[Fact]
67+
public void AMinimalEventWithSourceTypeIsValidJson()
68+
{
69+
AssertValidJson(log => log.Information("One {Property}", 42), sourceType: "A Test SourceType");
70+
}
71+
72+
[Fact]
73+
public void AMinimalEventWithHostIsValidJson()
74+
{
75+
AssertValidJson(log => log.Information("One {Property}", 42), host: "A Test Host");
76+
}
77+
78+
[Fact]
79+
public void AMinimalEventWithIndexIsValidJson()
80+
{
81+
AssertValidJson(log => log.Information("One {Property}", 42), host: "testindex");
82+
}
83+
5584
}
56-
}
85+
}

0 commit comments

Comments
 (0)