Skip to content

Commit

Permalink
fix settings check & tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bziobrowski committed Feb 21, 2024
1 parent b045431 commit 956abc0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/plugin/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (settings *Settings) isValid() (err error) {
if settings.Port <= 0 {
return ErrorMessageInvalidPort
}
if len(settings.TlsMode) == 0 {
if len(settings.Username) == 0 {
return ErrorMessageInvalidUserName
}
if len(settings.Password) == 0 {
Expand Down
6 changes: 4 additions & 2 deletions pkg/plugin/settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,15 @@ func TestLoadSettings(t *testing.T) {
name: "should converting string values to the correct type",
args: args{
config: backend.DataSourceInstanceSettings{
JSONData: []byte(`{"server": "test", "port": "1234", "timeout": "15", "queryTimeout": "25", "maxOpenConnections": 10, "maxIdleConnections": 5, "maxConnectionLifetime": 3600 }`),
DecryptedSecureJSONData: map[string]string{},
JSONData: []byte(`{"server": "test", "username": "u", "port": "1234", "timeout": "15", "queryTimeout": "25", "maxOpenConnections": 10, "maxIdleConnections": 5, "maxConnectionLifetime": 3600 }`),
DecryptedSecureJSONData: map[string]string{"password": "p"},
},
},
wantSettings: Settings{
Server: "test",
Port: 1234,
Username: "u",
Password: "p",
Timeout: "15",
QueryTimeout: "25",
MaxOpenConnections: 10,
Expand Down

0 comments on commit 956abc0

Please sign in to comment.