@@ -115,7 +115,7 @@ func newDBServiceUsecaseForEmptyPasswordTest(repo *fakeDBServiceRepoForPassword)
115115 return NewDBServiceUsecase (logger , repo , nil , pluginUC , opUC , projectUC , nil , envUC )
116116}
117117
118- func TestUpdateDBServiceByArgs_EmptyPasswordAllowed (t * testing.T ) {
118+ func TestUpdateDBServiceByArgs_EmptyPasswordRejected (t * testing.T ) {
119119 repo := & fakeDBServiceRepoForPassword {
120120 svc : & DBService {
121121 UID : "ds-1" ,
@@ -138,14 +138,14 @@ func TestUpdateDBServiceByArgs_EmptyPasswordAllowed(t *testing.T) {
138138 Password : & empty ,
139139 EnvironmentTagUID : "env-1" ,
140140 }, pkgConst .UIDOfUserAdmin )
141- if err ! = nil {
142- t .Fatalf ("expected Update with password=\" \" to succeed (not \" password can't be empty \" ), got: %v" , err )
141+ if err = = nil {
142+ t .Fatal ("expected Update with password=\" \" to fail" )
143143 }
144- if repo . updated == nil {
145- t .Fatal ("expected UpdateDBService to be called" )
144+ if ! strings . Contains ( err . Error (), "password can't be empty" ) {
145+ t .Fatalf ("expected \" password can't be empty \" , got: %v" , err )
146146 }
147- if repo .updated . Password != "" {
148- t .Fatalf ("expected stored password to be empty string, got %q" , repo . updated . Password )
147+ if repo .updated != nil {
148+ t .Fatal ("expected UpdateDBService not to be called when password is empty" )
149149 }
150150}
151151
@@ -163,13 +163,13 @@ func TestUpdateDBServiceByArgs_MissingHostStillRejected(t *testing.T) {
163163 },
164164 }
165165 uc := newDBServiceUsecaseForEmptyPasswordTest (repo )
166- empty := ""
166+ pwd := "not-empty "
167167 err := uc .UpdateDBServiceByArgs (context .Background (), "ds-1" , & BizDBServiceArgs {
168168 DBType : "GBase-8a" ,
169169 Host : "" ,
170170 Port : "5258" ,
171171 User : "root" ,
172- Password : & empty ,
172+ Password : & pwd ,
173173 EnvironmentTagUID : "env-1" ,
174174 }, pkgConst .UIDOfUserAdmin )
175175 if err == nil {
@@ -178,7 +178,4 @@ func TestUpdateDBServiceByArgs_MissingHostStillRejected(t *testing.T) {
178178 if ! strings .Contains (err .Error (), "host" ) {
179179 t .Fatalf ("expected host-related error, got: %v" , err )
180180 }
181- if strings .Contains (err .Error (), "password can't be empty" ) {
182- t .Fatalf ("must not fail on legacy empty-password check: %v" , err )
183- }
184181}
0 commit comments