diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-11-17 10:30:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-17 02:30:57 +0000 |
commit | 17d246cdcc0bf615ee4ba97a17c0f7e2c2f5f27f (patch) | |
tree | 541679b586056d9b5e011a92fd54c713265cb124 /modules/setting/database_test.go | |
parent | fce1d5d7dce6a16429d0fe043555eac2c083ae7b (diff) | |
download | gitea-17d246cdcc0bf615ee4ba97a17c0f7e2c2f5f27f.tar.gz gitea-17d246cdcc0bf615ee4ba97a17c0f7e2c2f5f27f.zip |
Fix incorrect pgsql conn builder behavior (#28085)
Fix #28083 and fix the tests
Diffstat (limited to 'modules/setting/database_test.go')
-rw-r--r-- | modules/setting/database_test.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/modules/setting/database_test.go b/modules/setting/database_test.go index 85271c36cb..1d5b416504 100644 --- a/modules/setting/database_test.go +++ b/modules/setting/database_test.go @@ -59,38 +59,39 @@ func Test_parsePostgreSQLHostPort(t *testing.T) { func Test_getPostgreSQLConnectionString(t *testing.T) { tests := []struct { Host string - Port string User string Passwd string Name string - Param string SSLMode string Output string }{ { Host: "/tmp/pg.sock", - Port: "4321", User: "testuser", Passwd: "space space !#$%^^%^```-=?=", Name: "gitea", - Param: "", SSLMode: "false", Output: "postgres://testuser:space%20space%20%21%23$%25%5E%5E%25%5E%60%60%60-=%3F=@:5432/gitea?host=%2Ftmp%2Fpg.sock&sslmode=false", }, { Host: "localhost", - Port: "1234", User: "pgsqlusername", Passwd: "I love Gitea!", Name: "gitea", - Param: "", SSLMode: "true", Output: "postgres://pgsqlusername:I%20love%20Gitea%21@localhost:5432/gitea?sslmode=true", }, + { + Host: "localhost:1234", + User: "user", + Passwd: "pass", + Name: "gitea?param=1", + Output: "postgres://user:pass@localhost:1234/gitea?param=1&sslmode=", + }, } for _, test := range tests { - connStr := getPostgreSQLConnectionString(test.Host, test.User, test.Passwd, test.Name, test.Param, test.SSLMode) + connStr := getPostgreSQLConnectionString(test.Host, test.User, test.Passwd, test.Name, test.SSLMode) assert.Equal(t, test.Output, connStr) } } |