@@ -12,7 +12,7 @@ import (
12
12
)
13
13
14
14
func Test_defaultInitDatabase_ErrorWhenCannotCreatePasswordFile (t * testing.T ) {
15
- err := defaultInitDatabase ("path_not_exists" , "path_not_exists" , "path_not_exists" , "Tom" , "Beer" , "" , os .Stderr )
15
+ err := defaultInitDatabase ("path_not_exists" , "path_not_exists" , "path_not_exists" , "Tom" , "Beer" , "" , "" , os .Stderr )
16
16
17
17
assert .EqualError (t , err , "unable to write password file to path_not_exists/pwfile" )
18
18
}
@@ -49,7 +49,7 @@ func Test_defaultInitDatabase_ErrorWhenCannotStartInitDBProcess(t *testing.T) {
49
49
50
50
_ , _ = logFile .Write ([]byte ("and here are the logs!" ))
51
51
52
- err = defaultInitDatabase (binTempDir , runtimeTempDir , filepath .Join (runtimeTempDir , "data" ), "Tom" , "Beer" , "" , logFile )
52
+ err = defaultInitDatabase (binTempDir , runtimeTempDir , filepath .Join (runtimeTempDir , "data" ), "Tom" , "Beer" , "" , "" , logFile )
53
53
54
54
assert .NotNil (t , err )
55
55
assert .Contains (t , err .Error (), fmt .Sprintf ("unable to init database using '%s/bin/initdb -A password -U Tom -D %s/data --pwfile=%s/pwfile'" ,
@@ -72,7 +72,7 @@ func Test_defaultInitDatabase_ErrorInvalidLocaleSetting(t *testing.T) {
72
72
}
73
73
}()
74
74
75
- err = defaultInitDatabase (tempDir , tempDir , filepath .Join (tempDir , "data" ), "postgres" , "postgres" , "en_XY" , os .Stderr )
75
+ err = defaultInitDatabase (tempDir , tempDir , filepath .Join (tempDir , "data" ), "postgres" , "postgres" , "en_XY" , "" , os .Stderr )
76
76
77
77
assert .NotNil (t , err )
78
78
assert .Contains (t , err .Error (), fmt .Sprintf ("unable to init database using '%s/bin/initdb -A password -U postgres -D %s/data --pwfile=%s/pwfile --locale=en_XY'" ,
@@ -81,6 +81,27 @@ func Test_defaultInitDatabase_ErrorInvalidLocaleSetting(t *testing.T) {
81
81
tempDir ))
82
82
}
83
83
84
+ func Test_defaultInitDatabase_ErrorInvalidEncodingSetting (t * testing.T ) {
85
+ tempDir , err := os .MkdirTemp ("" , "prepare_database_test" )
86
+ if err != nil {
87
+ panic (err )
88
+ }
89
+
90
+ defer func () {
91
+ if err := os .RemoveAll (tempDir ); err != nil {
92
+ panic (err )
93
+ }
94
+ }()
95
+
96
+ err = defaultInitDatabase (tempDir , tempDir , filepath .Join (tempDir , "data" ), "postgres" , "postgres" , "" , "invalid" , os .Stderr )
97
+
98
+ assert .NotNil (t , err )
99
+ assert .Contains (t , err .Error (), fmt .Sprintf ("unable to init database using '%s/bin/initdb -A password -U postgres -D %s/data --pwfile=%s/pwfile --encoding=invalid'" ,
100
+ tempDir ,
101
+ tempDir ,
102
+ tempDir ))
103
+ }
104
+
84
105
func Test_defaultInitDatabase_PwFileRemoved (t * testing.T ) {
85
106
tempDir , err := os .MkdirTemp ("" , "prepare_database_test" )
86
107
if err != nil {
0 commit comments