Fixed some tests to manually close account resolver

Those tests don't really start the server, so the account resolver's
internal expiration routine would be left running.
Doing an explicit close solves this issue.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
Ivan Kozlovic
2021-05-06 10:37:26 -06:00
parent 8499376575
commit f5eb8bef89
2 changed files with 6 additions and 0 deletions

View File

@@ -5755,6 +5755,9 @@ func TestJWTNoSystemAccountButNatsResolver(t *testing.T) {
defer removeFile(t, conf)
opts := LoadConfig(conf)
s, err := NewServer(opts)
// Since the server cannot be stopped, since it did not start,
// let's manually close the account resolver to avoid leaking go routines.
opts.AccountResolver.Close()
s.Shutdown()
require_Error(t, err)
require_Contains(t, err.Error(), "the system account needs to be specified in configuration or the operator jwt")

View File

@@ -2496,6 +2496,9 @@ func TestLeafNodeOperatorBadCfg(t *testing.T) {
s.Shutdown()
t.Fatal("Expected an error")
}
// Since the server cannot be stopped, since it did not start,
// let's manually close the account resolver to avoid leaking go routines.
opts.AccountResolver.Close()
if err.Error() != errorText {
t.Fatalf("Expected error %s but got %s", errorText, err)
}