@@ -6,15 +6,13 @@ import (
66 "fmt"
77 "net/http"
88 "net/http/httptest"
9- "os"
109 "sync"
1110 "testing"
1211
1312 "github.com/prometheus/client_golang/prometheus"
1413 dto "github.com/prometheus/client_model/go"
1514 "github.com/stretchr/testify/assert"
1615 "github.com/stretchr/testify/mock"
17- "github.com/stretchr/testify/require"
1816
1917 "github.com/stellar/go/historyarchive"
2018 "github.com/stellar/go/network"
@@ -138,9 +136,7 @@ type testLedgerHeader struct {
138136}
139137
140138func TestCaptiveNew (t * testing.T ) {
141- storagePath , err := os .MkdirTemp ("" , "captive-core-*" )
142- require .NoError (t , err )
143- defer os .RemoveAll (storagePath )
139+ storagePath := t .TempDir ()
144140
145141 var userAgent string
146142 server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
@@ -173,9 +169,7 @@ func TestCaptiveNew(t *testing.T) {
173169}
174170
175171func TestCaptiveNewUnsupportedProtocolVersion (t * testing.T ) {
176- storagePath , err := os .MkdirTemp ("" , "captive-core-*" )
177- require .NoError (t , err )
178- defer os .RemoveAll (storagePath )
172+ storagePath := t .TempDir ()
179173
180174 server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
181175 w .WriteHeader (http .StatusOK )
@@ -186,7 +180,7 @@ func TestCaptiveNewUnsupportedProtocolVersion(t *testing.T) {
186180 networkPassphrase := network .PublicNetworkPassphrase
187181 historyURLs := []string {server .URL }
188182
189- _ , err = NewCaptive (
183+ _ , err : = NewCaptive (
190184 CaptiveCoreConfig {
191185 BinaryPath : executablePath ,
192186 NetworkPassphrase : networkPassphrase ,
@@ -1022,9 +1016,7 @@ func TestCaptiveGetLedger_NextLedger0RangeFromIsSmallerThanLedgerFromBuffer(t *t
10221016}
10231017
10241018func TestCaptiveStellarCore_PrepareRangeAfterClose (t * testing.T ) {
1025- storagePath , err := os .MkdirTemp ("" , "captive-core-*" )
1026- require .NoError (t , err )
1027- defer os .RemoveAll (storagePath )
1019+ storagePath := t .TempDir ()
10281020
10291021 ctx := context .Background ()
10301022 executablePath := "/etc/stellar-core"
0 commit comments