Skip to content

Commit 956abc0

Browse files
committed
fix settings check & tests
1 parent b045431 commit 956abc0

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

pkg/plugin/settings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (settings *Settings) isValid() (err error) {
4949
if settings.Port <= 0 {
5050
return ErrorMessageInvalidPort
5151
}
52-
if len(settings.TlsMode) == 0 {
52+
if len(settings.Username) == 0 {
5353
return ErrorMessageInvalidUserName
5454
}
5555
if len(settings.Password) == 0 {

pkg/plugin/settings_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,15 @@ func TestLoadSettings(t *testing.T) {
133133
name: "should converting string values to the correct type",
134134
args: args{
135135
config: backend.DataSourceInstanceSettings{
136-
JSONData: []byte(`{"server": "test", "port": "1234", "timeout": "15", "queryTimeout": "25", "maxOpenConnections": 10, "maxIdleConnections": 5, "maxConnectionLifetime": 3600 }`),
137-
DecryptedSecureJSONData: map[string]string{},
136+
JSONData: []byte(`{"server": "test", "username": "u", "port": "1234", "timeout": "15", "queryTimeout": "25", "maxOpenConnections": 10, "maxIdleConnections": 5, "maxConnectionLifetime": 3600 }`),
137+
DecryptedSecureJSONData: map[string]string{"password": "p"},
138138
},
139139
},
140140
wantSettings: Settings{
141141
Server: "test",
142142
Port: 1234,
143+
Username: "u",
144+
Password: "p",
143145
Timeout: "15",
144146
QueryTimeout: "25",
145147
MaxOpenConnections: 10,

0 commit comments

Comments
 (0)