4
4
"database/sql"
5
5
"fmt"
6
6
"io/ioutil"
7
- "os"
8
7
"path/filepath"
9
- "strconv"
10
8
"strings"
11
9
"testing"
12
10
@@ -21,15 +19,19 @@ func Test_AllMajorVersions(t *testing.T) {
21
19
embeddedpostgres .V10 ,
22
20
embeddedpostgres .V9 ,
23
21
}
24
- tempExtractLocation , err := ioutil .TempDir ("" , "embedded_postgres_go_tests" )
22
+
23
+ tempExtractLocation , err := ioutil .TempDir ("" , "embedded_postgres_tests" )
25
24
if err != nil {
26
25
t .Fatal (err )
27
26
}
28
27
29
- for testNumber , version := range allVersions {
28
+ for i , v := range allVersions {
29
+ testNumber := i
30
+ version := v
30
31
t .Run (fmt .Sprintf ("MajorVersion_%s" , version ), func (t * testing.T ) {
31
32
port := uint32 (5555 + testNumber )
32
- runtimePath := filepath .Join (tempExtractLocation , strconv .Itoa (testNumber ))
33
+ runtimePath := filepath .Join (tempExtractLocation , string (version ))
34
+
33
35
database := embeddedpostgres .NewDatabase (embeddedpostgres .DefaultConfig ().
34
36
Version (version ).
35
37
Port (port ).
@@ -65,15 +67,13 @@ func Test_AllMajorVersions(t *testing.T) {
65
67
}
66
68
})
67
69
}
68
- if err := os .RemoveAll (tempExtractLocation ); err != nil {
69
- t .Fatal (err )
70
- }
71
70
}
72
71
73
72
func shutdownDBAndFail (t * testing.T , err error , db * embeddedpostgres.EmbeddedPostgres , version embeddedpostgres.PostgresVersion ) {
74
73
if err := db .Stop (); err != nil {
75
74
t .Fatalf ("Failed for version %s with error %s" , version , err )
76
75
}
76
+
77
77
t .Fatalf ("Failed for version %s with error %s" , version , err )
78
78
}
79
79
0 commit comments