-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Public api and other missing build fixes (#2)
* Public API analyzer * Code docs * Enabled test coverage * Test native AOT rename
- Loading branch information
Showing
73 changed files
with
4,059 additions
and
599 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,26 +62,25 @@ jobs: | |
# https://github.com/MarcoRossignoli/coverlet/blob/master/Documentation/KnownIssues.md#tests-fail-if-assembly-is-strong-named | ||
run: dotnet test --no-build --logger:"console;verbosity=normal" --collect:"XPlat Code Coverage" --settings Default.runsettings -- RunConfiguration.DisableAppDomain=true | ||
|
||
# TODO: Enable code coverage upload | ||
# - name: Upload coverage reports to Codecov | ||
# # PRs from external contributors fail: https://github.com/codecov/feedback/issues/301 | ||
# # Only upload coverage reports for PRs from the same repo (not forks) | ||
# if: github.event.pull_request.head.repo.full_name == github.repository || github.ref == 'refs/heads/main' | ||
# uses: codecov/[email protected] | ||
# with: | ||
# token: ${{ secrets.CODECOV_TOKEN }} | ||
|
||
- name: Check Native AOT | ||
- name: Upload coverage reports to Codecov | ||
# PRs from external contributors fail: https://github.com/codecov/feedback/issues/301 | ||
# Only upload coverage reports for PRs from the same repo (not forks) | ||
if: github.event.pull_request.head.repo.full_name == github.repository || github.ref == 'refs/heads/main' | ||
uses: codecov/[email protected] | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
|
||
- name: Test Native AOT | ||
shell: bash | ||
run: | | ||
echo ">> Set up for AOT compilation..." | ||
export exe_file=NATS.Jwt.CheckNativeAot | ||
export exe_file=NATS.Jwt.TestNativeAot | ||
export exe_type=ELF | ||
export dotnet_runtime_id=linux-x64 | ||
echo ">> Checking OS..." | ||
if [ "${{ matrix.os }}" = "windows-latest" ]; then | ||
export exe_file=NATS.Jwt.CheckNativeAot.exe | ||
export exe_file=NATS.Jwt.TestNativeAot.exe | ||
export exe_type=PE32 | ||
export dotnet_runtime_id=win-x64 | ||
elif [ "${{ matrix.os }}" = "macos-latest" ]; then | ||
|
@@ -90,7 +89,7 @@ jobs: | |
fi | ||
echo ">> Publishing..." | ||
cd NATS.Jwt.CheckNativeAot | ||
cd NATS.Jwt.TestNativeAot | ||
rm -rf bin obj | ||
dotnet publish -r $dotnet_runtime_id -c Release -o dist | tee output.txt | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) The NATS Authors. | ||
// Licensed under the Apache License, Version 2.0. | ||
|
||
namespace NATS.Jwt.TestNativeAot; | ||
|
||
/// <summary> | ||
/// The Assert class provides methods for performing assertions in tests. | ||
/// </summary> | ||
public static class Assert | ||
{ | ||
/// <summary> | ||
/// Checks if two strings are equal. | ||
/// </summary> | ||
/// <param name="expected">The first string to compare.</param> | ||
/// <param name="actual">The second string to compare.</param> | ||
/// <param name="name">The name of the comparison for error reporting.</param> | ||
/// <exception cref="Exception">Thrown when the strings are not equal.</exception> | ||
public static void Equal(string expected, string actual, string name) | ||
{ | ||
if (!string.Equals(expected, actual)) | ||
{ | ||
throw new Exception($"Strings are not equal ({name}).\n---\nExpected:\n{expected}\nActual:\n{actual}\n---"); | ||
} | ||
|
||
Console.WriteLine($"OK {name}"); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// Copyright (c) The NATS Authors. | ||
// Licensed under the Apache License, Version 2.0. | ||
|
||
using System.Text.Json; | ||
using NATS.Jwt.Models; | ||
using Xunit; | ||
|
||
namespace NATS.Jwt.Tests.Models; | ||
|
||
public class JetStreamLimitsTests | ||
{ | ||
[Fact] | ||
public void SerializeJetStreamLimits_AllPropertiesSet() | ||
{ | ||
var limits = new JetStreamLimits | ||
{ | ||
MemoryStorage = 1024, | ||
DiskStorage = 2048, | ||
Streams = 10, | ||
Consumer = 5, | ||
MaxAckPending = 100, | ||
MemoryMaxStreamBytes = 512, | ||
DiskMaxStreamBytes = 1024, | ||
MaxBytesRequired = true, | ||
}; | ||
|
||
var json = JsonSerializer.Serialize(limits); | ||
var expected = "{\"mem_storage\":1024,\"disk_storage\":2048,\"streams\":10,\"consumer\":5,\"max_ack_pending\":100,\"mem_max_stream_bytes\":512,\"disk_max_stream_bytes\":1024,\"max_bytes_required\":true}"; | ||
|
||
Assert.Equal(expected, json); | ||
} | ||
|
||
[Fact] | ||
public void SerializeJetStreamLimits_DefaultValues() | ||
{ | ||
var limits = new JetStreamLimits(); | ||
|
||
var json = JsonSerializer.Serialize(limits); | ||
var expected = "{}"; | ||
|
||
Assert.Equal(expected, json); | ||
} | ||
|
||
[Fact] | ||
public void DeserializeJetStreamLimits_AllPropertiesSet() | ||
{ | ||
var json = "{\"mem_storage\":1024,\"disk_storage\":2048,\"streams\":10,\"consumer\":5,\"max_ack_pending\":100,\"mem_max_stream_bytes\":512,\"disk_max_stream_bytes\":1024,\"max_bytes_required\":true}"; | ||
|
||
var limits = JsonSerializer.Deserialize<JetStreamLimits>(json); | ||
|
||
Assert.NotNull(limits); | ||
Assert.Equal(1024, limits.MemoryStorage); | ||
Assert.Equal(2048, limits.DiskStorage); | ||
Assert.Equal(10, limits.Streams); | ||
Assert.Equal(5, limits.Consumer); | ||
Assert.Equal(100, limits.MaxAckPending); | ||
Assert.Equal(512, limits.MemoryMaxStreamBytes); | ||
Assert.Equal(1024, limits.DiskMaxStreamBytes); | ||
Assert.True(limits.MaxBytesRequired); | ||
} | ||
|
||
[Fact] | ||
public void DeserializeJetStreamLimits_PartialProperties() | ||
{ | ||
var json = "{\"mem_storage\":1024,\"streams\":10,\"max_bytes_required\":true}"; | ||
|
||
var limits = JsonSerializer.Deserialize<JetStreamLimits>(json); | ||
|
||
Assert.NotNull(limits); | ||
Assert.Equal(1024, limits.MemoryStorage); | ||
Assert.Equal(0, limits.DiskStorage); | ||
Assert.Equal(10, limits.Streams); | ||
Assert.Equal(0, limits.Consumer); | ||
Assert.Equal(0, limits.MaxAckPending); | ||
Assert.Equal(0, limits.MemoryMaxStreamBytes); | ||
Assert.Equal(0, limits.DiskMaxStreamBytes); | ||
Assert.True(limits.MaxBytesRequired); | ||
} | ||
|
||
[Fact] | ||
public void DeserializeJetStreamLimits_EmptyJson() | ||
{ | ||
var json = "{}"; | ||
|
||
var limits = JsonSerializer.Deserialize<JetStreamLimits>(json); | ||
|
||
Assert.NotNull(limits); | ||
Assert.Equal(0, limits.MemoryStorage); | ||
Assert.Equal(0, limits.DiskStorage); | ||
Assert.Equal(0, limits.Streams); | ||
Assert.Equal(0, limits.Consumer); | ||
Assert.Equal(0, limits.MaxAckPending); | ||
Assert.Equal(0, limits.MemoryMaxStreamBytes); | ||
Assert.Equal(0, limits.DiskMaxStreamBytes); | ||
Assert.False(limits.MaxBytesRequired); | ||
} | ||
} |
Oops, something went wrong.