@@ -6,15 +6,13 @@ import (
6
6
"fmt"
7
7
"net/http"
8
8
"net/http/httptest"
9
- "os"
10
9
"sync"
11
10
"testing"
12
11
13
12
"github.com/prometheus/client_golang/prometheus"
14
13
dto "github.com/prometheus/client_model/go"
15
14
"github.com/stretchr/testify/assert"
16
15
"github.com/stretchr/testify/mock"
17
- "github.com/stretchr/testify/require"
18
16
19
17
"github.com/stellar/go/historyarchive"
20
18
"github.com/stellar/go/network"
@@ -138,9 +136,7 @@ type testLedgerHeader struct {
138
136
}
139
137
140
138
func 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 ()
144
140
145
141
var userAgent string
146
142
server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
@@ -173,9 +169,7 @@ func TestCaptiveNew(t *testing.T) {
173
169
}
174
170
175
171
func 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 ()
179
173
180
174
server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
181
175
w .WriteHeader (http .StatusOK )
@@ -186,7 +180,7 @@ func TestCaptiveNewUnsupportedProtocolVersion(t *testing.T) {
186
180
networkPassphrase := network .PublicNetworkPassphrase
187
181
historyURLs := []string {server .URL }
188
182
189
- _ , err = NewCaptive (
183
+ _ , err : = NewCaptive (
190
184
CaptiveCoreConfig {
191
185
BinaryPath : executablePath ,
192
186
NetworkPassphrase : networkPassphrase ,
@@ -1022,9 +1016,7 @@ func TestCaptiveGetLedger_NextLedger0RangeFromIsSmallerThanLedgerFromBuffer(t *t
1022
1016
}
1023
1017
1024
1018
func 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 ()
1028
1020
1029
1021
ctx := context .Background ()
1030
1022
executablePath := "/etc/stellar-core"
0 commit comments