feat(captain): gate custom tools

This commit is contained in:
2026-06-07 15:50:23 +08:00
parent 0aff792b40
commit 0d8de3be0b
7 changed files with 81 additions and 16 deletions
@@ -46,8 +46,8 @@ func setupCaptainResourceParityTest(t *testing.T) (*gin.Engine, *gorm.DB, *model
sqlDB.Close()
})
account := &model.Account{Name: "Captain Account", Locale: "en", Active: true}
otherAccount := &model.Account{Name: "Other Account", Locale: "en", Active: true}
account := &model.Account{Name: "Captain Account", Locale: "en", Active: true, FeatureFlags: `{"custom_tools":true}`}
otherAccount := &model.Account{Name: "Other Account", Locale: "en", Active: true, FeatureFlags: `{"custom_tools":true}`}
require.NoError(t, db.Create(account).Error)
require.NoError(t, db.Create(otherAccount).Error)
assistant := &model.CaptainAssistant{AccountID: account.ID, Name: "Fin", Description: "Support", Config: json.RawMessage(`{}`), Status: model.AssistantStatusActive}
@@ -59,7 +59,8 @@ func setupCaptainResourceParityTest(t *testing.T) (*gin.Engine, *gorm.DB, *model
scenarioHandler := NewCaptainScenarioHandler(scenarioSvc)
toolRepo := repository.NewCaptainCustomToolRepo(db)
toolSvc := service.NewCaptainCustomToolService(toolRepo)
accountRepo := repository.NewAccountRepo(db)
toolSvc := service.NewCaptainCustomToolService(toolRepo, accountRepo)
toolSvc.SetHTTPClient(fakeCaptainToolHTTPDoer(func(req *http.Request) (*http.Response, error) {
return &http.Response{StatusCode: http.StatusCreated, Body: io.NopCloser(strings.NewReader(`{"ok":true}`)), Header: make(http.Header)}, nil
}))