feat(batch6-task6): port t1 opts reload jwt tests
This commit is contained in:
@@ -8,25 +8,97 @@ public sealed class ConfigReloaderTests
|
||||
[Fact] // T:2766
|
||||
public void ConfigReloadBoolFlags_ShouldSucceed()
|
||||
{
|
||||
var options = new ServerOptions();
|
||||
var errors = new List<Exception>();
|
||||
var warnings = new List<Exception>();
|
||||
static string WriteConfig(string body)
|
||||
{
|
||||
var tempFile = Path.GetTempFileName();
|
||||
File.WriteAllText(tempFile, body);
|
||||
return tempFile;
|
||||
}
|
||||
|
||||
ServerOptions.ParseCluster(
|
||||
new Dictionary<string, object?>
|
||||
try
|
||||
{
|
||||
var cases = new[]
|
||||
{
|
||||
["no_advertise"] = true,
|
||||
["connect_backoff"] = true,
|
||||
},
|
||||
options,
|
||||
errors,
|
||||
warnings);
|
||||
new
|
||||
{
|
||||
Config = """
|
||||
{
|
||||
"host": "127.0.0.1",
|
||||
"port": 4222,
|
||||
"logtime": false
|
||||
}
|
||||
""",
|
||||
Args = new[] { "-T" },
|
||||
Validate = (Action<ServerOptions>)(opts => opts.Logtime.ShouldBeTrue()),
|
||||
},
|
||||
new
|
||||
{
|
||||
Config = """
|
||||
{
|
||||
"host": "127.0.0.1",
|
||||
"port": 4222,
|
||||
"debug": true
|
||||
}
|
||||
""",
|
||||
Args = new[] { "-D=false" },
|
||||
Validate = (Action<ServerOptions>)(opts => opts.Debug.ShouldBeFalse()),
|
||||
},
|
||||
new
|
||||
{
|
||||
Config = """
|
||||
{
|
||||
"host": "127.0.0.1",
|
||||
"port": 4222,
|
||||
"trace": true
|
||||
}
|
||||
""",
|
||||
Args = new[] { "-V=false" },
|
||||
Validate = (Action<ServerOptions>)(opts => opts.Trace.ShouldBeFalse()),
|
||||
},
|
||||
new
|
||||
{
|
||||
Config = """
|
||||
{
|
||||
"host": "127.0.0.1",
|
||||
"port": 4222,
|
||||
"cluster": { "port": 6222, "no_advertise": true }
|
||||
}
|
||||
""",
|
||||
Args = new[] { "--no_advertise=false" },
|
||||
Validate = (Action<ServerOptions>)(opts => opts.Cluster.NoAdvertise.ShouldBeFalse()),
|
||||
},
|
||||
new
|
||||
{
|
||||
Config = """
|
||||
{
|
||||
"host": "127.0.0.1",
|
||||
"port": 4222,
|
||||
"jetstream": true
|
||||
}
|
||||
""",
|
||||
Args = new[] { "--js=false" },
|
||||
Validate = (Action<ServerOptions>)(opts => opts.JetStream.ShouldBeFalse()),
|
||||
},
|
||||
};
|
||||
|
||||
errors.ShouldBeEmpty();
|
||||
options.Cluster.NoAdvertise.ShouldBeTrue();
|
||||
options.Cluster.ConnectBackoff.ShouldBeTrue();
|
||||
options.InConfig.TryGetValue("Cluster.NoAdvertise", out var explicitValue).ShouldBeTrue();
|
||||
explicitValue.ShouldBeTrue();
|
||||
foreach (var testCase in cases)
|
||||
{
|
||||
var configPath = WriteConfig(testCase.Config);
|
||||
var args = new List<string> { "-c", configPath };
|
||||
args.AddRange(testCase.Args);
|
||||
|
||||
var (options, error) = ServerOptions.ConfigureOptions(args, null, null, null);
|
||||
|
||||
error.ShouldBeNull();
|
||||
options.ShouldNotBeNull();
|
||||
testCase.Validate(options!);
|
||||
File.Delete(configPath);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ServerOptions.FlagSnapshot = null;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user