mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
Use testing.TempDir() where possible
Refactor tests to use go built-in temporary directory utility for tests. Also avoid binding to default port (which may be in use)
This commit is contained in:
@@ -357,7 +357,6 @@ func TestReloadDoesNotWipeAccountsWithOperatorMode(t *testing.T) {
|
||||
`
|
||||
contents := strings.Replace(fmt.Sprintf(cf, "", sysPub, sysPub, sysJWT, accPub, accJWT), "\n\t", "\n", -1)
|
||||
conf := createConfFile(t, []byte(contents))
|
||||
defer removeFile(t, conf)
|
||||
|
||||
s, opts := RunServerWithConfig(conf)
|
||||
defer s.Shutdown()
|
||||
@@ -367,7 +366,6 @@ func TestReloadDoesNotWipeAccountsWithOperatorMode(t *testing.T) {
|
||||
contents2 := strings.Replace(fmt.Sprintf(cf, routeStr, sysPub, sysPub, sysJWT, accPub, accJWT), "\n\t", "\n", -1)
|
||||
|
||||
conf2 := createConfFile(t, []byte(contents2))
|
||||
defer removeFile(t, conf2)
|
||||
|
||||
s2, opts2 := RunServerWithConfig(conf2)
|
||||
defer s2.Shutdown()
|
||||
@@ -481,7 +479,6 @@ func TestReloadDoesUpdateAccountsWithMemoryResolver(t *testing.T) {
|
||||
`
|
||||
contents := strings.Replace(fmt.Sprintf(cf, "", sysPub, sysPub, sysJWT, accPub, accJWT), "\n\t", "\n", -1)
|
||||
conf := createConfFile(t, []byte(contents))
|
||||
defer removeFile(t, conf)
|
||||
|
||||
s, opts := RunServerWithConfig(conf)
|
||||
defer s.Shutdown()
|
||||
@@ -573,7 +570,6 @@ func TestReloadFailsWithBadAccountsWithMemoryResolver(t *testing.T) {
|
||||
`
|
||||
contents := strings.Replace(fmt.Sprintf(cf, "", sysPub, sysPub, sysJWT, apub, ajwt), "\n\t", "\n", -1)
|
||||
conf := createConfFile(t, []byte(contents))
|
||||
defer removeFile(t, conf)
|
||||
|
||||
s, _ := RunServerWithConfig(conf)
|
||||
defer s.Shutdown()
|
||||
@@ -637,7 +633,6 @@ func TestConnsRequestDoesNotLoadAccountCheckingConnLimits(t *testing.T) {
|
||||
`
|
||||
contents := strings.Replace(fmt.Sprintf(cf, "", sysPub, sysPub, sysJWT, accPub, accJWT), "\n\t", "\n", -1)
|
||||
conf := createConfFile(t, []byte(contents))
|
||||
defer removeFile(t, conf)
|
||||
|
||||
s, opts := RunServerWithConfig(conf)
|
||||
defer s.Shutdown()
|
||||
@@ -647,7 +642,6 @@ func TestConnsRequestDoesNotLoadAccountCheckingConnLimits(t *testing.T) {
|
||||
contents2 := strings.Replace(fmt.Sprintf(cf, routeStr, sysPub, sysPub, sysJWT, accPub, accJWT), "\n\t", "\n", -1)
|
||||
|
||||
conf2 := createConfFile(t, []byte(contents2))
|
||||
defer removeFile(t, conf2)
|
||||
|
||||
s2, _ := RunServerWithConfig(conf2)
|
||||
defer s2.Shutdown()
|
||||
|
||||
Reference in New Issue
Block a user