mirror of
https://github.com/langgenius/dify-plugin-daemon.git
synced 2026-07-22 01:35:24 -04:00
4b75eed6b7
* feat: add support for PgBouncer in database initialization * refactor: consolidate gorm configuration for database connection * Add MySQL and multi-driver DB integration tests (#535) * feat: streamline integration tests by using a centralized docker-compose file * fix: add timeout * refactor: replace inline service definitions with docker-compose action for integration tests * fix: update pgbouncer image and environment variable names for consistency
62 lines
1.2 KiB
Go
62 lines
1.2 KiB
Go
package dbintegration_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/langgenius/dify-plugin-daemon/internal/db"
|
|
"github.com/langgenius/dify-plugin-daemon/internal/types/app"
|
|
)
|
|
|
|
func TestInitDB(t *testing.T) {
|
|
cases := []struct {
|
|
name string
|
|
config app.Config
|
|
}{
|
|
{
|
|
name: "postgresql",
|
|
config: app.Config{
|
|
DBType: app.DB_TYPE_POSTGRESQL,
|
|
DBUsername: "postgres",
|
|
DBPassword: "difyai123456",
|
|
DBHost: "localhost",
|
|
DBPort: 5432,
|
|
DBDatabase: "dify_plugin_daemon",
|
|
DBSslMode: "disable",
|
|
},
|
|
},
|
|
{
|
|
name: "pgbouncer",
|
|
config: app.Config{
|
|
DBType: app.DB_TYPE_PG_BOUNCER,
|
|
DBUsername: "postgres",
|
|
DBPassword: "difyai123456",
|
|
DBHost: "localhost",
|
|
DBPort: 6432,
|
|
DBDatabase: "dify_plugin_daemon",
|
|
DBSslMode: "disable",
|
|
},
|
|
},
|
|
{
|
|
name: "mysql",
|
|
config: app.Config{
|
|
DBType: app.DB_TYPE_MYSQL,
|
|
DBUsername: "root",
|
|
DBPassword: "difyai123456",
|
|
DBHost: "localhost",
|
|
DBPort: 3306,
|
|
DBDatabase: "dify_plugin_daemon",
|
|
DBSslMode: "disable",
|
|
},
|
|
},
|
|
}
|
|
|
|
for _, tc := range cases {
|
|
tc := tc
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
tc.config.SetDefault()
|
|
db.Init(&tc.config)
|
|
db.Close()
|
|
})
|
|
}
|
|
}
|