Files
Jay Brown 72de690894 Merged in feature/chatbot1 (pull request #223)
Chatbot functionality

* baseline working

* missing test file

* more tests
2026-05-07 20:56:18 +00:00

97 lines
3.4 KiB
Go

package queryapi_test
import (
queryapi "queryorchestration/api/queryAPI"
"queryorchestration/internal/backgroundtask"
"queryorchestration/internal/bot"
"queryorchestration/internal/client"
clientupdate "queryorchestration/internal/client/update"
"queryorchestration/internal/collector"
collectorset "queryorchestration/internal/collector/set"
"queryorchestration/internal/customschema"
"queryorchestration/internal/document"
documentbatch "queryorchestration/internal/document/batch"
documentdownload "queryorchestration/internal/document/download"
documentupload "queryorchestration/internal/document/upload"
"queryorchestration/internal/eula"
"queryorchestration/internal/export"
"queryorchestration/internal/fieldextraction"
"queryorchestration/internal/folder"
"queryorchestration/internal/label"
"queryorchestration/internal/server/api"
"queryorchestration/internal/serviceconfig/chatbot"
"queryorchestration/internal/serviceconfig/queue/clientsync"
"queryorchestration/internal/uisettings"
)
// ControllerConfig provides test configuration for API controllers.
// Note: Query-related configurations have been removed. See remove_query_plan.md.
//
// ChatbotConfig is embedded so initializeTestConfig can populate it
// from the same env vars the production binary reads. Without this
// embedding, bot.New would reject the empty config in
// createControllerServices.
type ControllerConfig struct {
api.BaseConfig
clientsync.ClientSyncConfig
chatbot.ChatbotConfig
BackgroundRunner *backgroundtask.Runner
}
// GetBackgroundRunner returns the background runner for batch processing.
func (c *ControllerConfig) GetBackgroundRunner() *backgroundtask.Runner {
return c.BackgroundRunner
}
// createControllerServices creates a Services struct for testing.
// Note: Query-related services have been removed. See remove_query_plan.md.
func createControllerServices(cfg *ControllerConfig) *queryapi.Services {
exp := export.New()
col := collector.New(cfg)
colupdate := collectorset.New(cfg, &collectorset.Services{
Collector: col,
})
cli := client.New(cfg)
cliUpdate := clientupdate.New(cfg, &clientupdate.Services{
Client: cli,
})
doc := document.New(cfg)
docup := documentupload.New(cfg)
docdownload := documentdownload.New(cfg)
docbatch := documentbatch.New(cfg)
fieldext := fieldextraction.New(cfg)
fld := folder.New(cfg)
lbl := label.New(cfg)
eul := eula.New(cfg)
uiSvc := uisettings.New(cfg)
customSchema := customschema.New(cfg, &customschema.SchemaValidator{}, customschema.NewSlogAuditSink(cfg.GetLogger()))
// Bot service requires a validated ChatbotConfig. The test env in
// internal/test/container.go and initializeTestConfig set the five
// CHATBOT_* variables to placeholder values that pass Validate. Any
// failure here represents a missing test-env wiring, so we panic
// rather than silently continuing with a nil service.
botSvc, err := bot.New(cfg.ChatbotConfig, cfg)
if err != nil {
panic("test: bot.New failed: " + err.Error())
}
return &queryapi.Services{
Export: exp,
Collector: col,
CollectorSet: colupdate,
Client: cli,
ClientUpdate: cliUpdate,
Document: doc,
DocumentUpload: docup,
DocumentDownload: docdownload,
DocumentBatch: docbatch,
UISettings: uiSvc,
FieldExtraction: fieldext,
CustomSchema: customSchema,
Folder: fld,
Label: lbl,
Eula: eul,
Bot: botSvc,
}
}