feat: initialize configuration and enhance IPC handling in task runner tests

- Added configuration initialization in db.go to ensure proper setup of application settings.
- Refactored runner_test.go to streamline IPC message handling by introducing a setupPipe function and an initRunner function for better readability and maintainability.
- Improved synchronization in tests by using channels for signaling readiness and processing, enhancing the reliability of IPC message handling.
- Updated test cases to validate IPC message processing and error handling, ensuring robustness in the task runner's functionality.
This commit is contained in:
Marvin Zhang
2025-01-06 14:41:38 +08:00
parent 8aa801e2ba
commit f5d9ccfbfc
2 changed files with 184 additions and 218 deletions

View File

@@ -1,10 +1,15 @@
package mongo
import (
"github.com/crawlab-team/crawlab/core/config"
"github.com/spf13/viper"
"go.mongodb.org/mongo-driver/mongo"
)
func init() {
config.InitConfig()
}
func GetMongoDb(dbName string) *mongo.Database {
// Use default database name if not provided
if dbName == "" {