diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-01-07 12:39:27 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-01-12 14:22:49 +0300 |
commit | 56683e8fc3f164a5276937cd5b4e4fdd03e09ed3 (patch) | |
tree | 80a68f8ba4f015ced03c31540a5a8618009d0623 /internal/testhelper/testserver.go | |
parent | 233941559401e2415b5707c12e92e2698daca50c (diff) |
testhelper: Assert that closing listeners succeeds
While not of importance for test results per se, let's assert that
closing of listeners succeeds.
Diffstat (limited to 'internal/testhelper/testserver.go')
-rw-r--r-- | internal/testhelper/testserver.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/internal/testhelper/testserver.go b/internal/testhelper/testserver.go index d977afce8..85563981f 100644 --- a/internal/testhelper/testserver.go +++ b/internal/testhelper/testserver.go @@ -143,11 +143,6 @@ func (p *TestServer) Start(t testing.TB) { praefectServerSocketPath := GetTemporaryGitalySocketFileName(t) - configFilePath := filepath.Join(tempDir, "config.toml") - configFile, err := os.Create(configFilePath) - require.NoError(t, err) - defer configFile.Close() - c := praefectconfig.Config{ SocketPath: praefectServerSocketPath, Auth: auth.Config{ @@ -178,8 +173,13 @@ func (p *TestServer) Start(t testing.TB) { }) } + configFilePath := filepath.Join(tempDir, "config.toml") + configFile, err := os.Create(configFilePath) + require.NoError(t, err) + defer MustClose(t, configFile) + require.NoError(t, toml.NewEncoder(configFile).Encode(&c)) - require.NoError(t, configFile.Close()) + require.NoError(t, configFile.Sync()) cmd := exec.Command(praefectBinPath, "-config", configFilePath) cmd.Stderr = os.Stderr @@ -202,7 +202,7 @@ func (p *TestServer) Start(t testing.TB) { conn, err := grpc.Dial("unix://"+praefectServerSocketPath, opts...) require.NoError(t, err) - defer conn.Close() + defer MustClose(t, conn) waitHealthy(t, conn, 3, time.Second) @@ -233,7 +233,7 @@ func (p *TestServer) listen(t testing.TB) string { conn, err := grpc.Dial("unix://"+socket, opts...) require.NoError(t, err) - defer conn.Close() + defer MustClose(t, conn) waitHealthy(t, conn, 3, time.Second) } |