feat(p7-02): fill opts_test.go stubs — ServerOptionsTests
Write 3 unit tests portable without a running server:
- ListenMonitoringDefault (T:2524): SetBaselineOptions propagates Host → HttpHost
- GetStorageSize (T:2576): StorageSizeJsonConverter.Parse K/M/G/T suffixes
- ClusterNameAndGatewayNameConflict (T:2571): ValidateOptions returns ErrClusterNameConfigConflict
Mark 74 opts_test.go stubs deferred: tests require either the NATS
conf-format parser (not yet ported), a running server (RunServer/NewServer),
or CLI flag-parsing infrastructure (ConfigureOptions).
Fix StorageSizeJsonConverter.Parse to return 0 for empty input,
matching Go getStorageSize("") == (0, nil).
Total unit tests: 638 passing.
This commit is contained in:
@@ -152,6 +152,8 @@ public sealed class StorageSizeJsonConverter : JsonConverter<long>
|
||||
|
||||
public static long Parse(string s)
|
||||
{
|
||||
// Mirrors Go getStorageSize: empty string returns 0 with no error.
|
||||
if (string.IsNullOrWhiteSpace(s)) return 0;
|
||||
if (long.TryParse(s, out var n)) return n;
|
||||
var m = Pattern.Match(s.Trim());
|
||||
if (!m.Success) throw new FormatException($"Invalid storage size: \"{s}\"");
|
||||
|
||||
Reference in New Issue
Block a user