HH-606: cover soft-deleted inbox assistants (#162)
* test(HH-606): cover soft-deleted inbox assistants * test(HH-606): bind soft-deleted inbox to persisted assistant --------- Co-authored-by: Rogee <rogee@ipao.vip>
This commit is contained in:
@@ -555,6 +555,35 @@ func (s *ConversationCrudTestSuite) TestInboxAssistant_ReturnsNilWhenBoundAssist
|
||||
assertUnavailable()
|
||||
}
|
||||
|
||||
func (s *ConversationCrudTestSuite) TestInboxAssistant_ReturnsNilWhenCaptainInboxSoftDeleted() {
|
||||
assistant := &model.CaptainAssistant{AccountID: s.testAccount.ID, Name: "Deleted Binding Helper", Config: json.RawMessage(`{}`), Status: model.AssistantStatusActive}
|
||||
s.Require().NoError(s.db.Create(assistant).Error)
|
||||
binding := &model.CaptainInbox{AccountID: s.testAccount.ID, AssistantID: assistant.ID, InboxID: s.testInbox.ID}
|
||||
s.Require().NoError(s.db.Create(binding).Error)
|
||||
s.Require().NoError(s.db.Delete(binding).Error)
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
req, _ := http.NewRequest("GET", s.convURL(s.testConv.ID)+"/inbox_assistant", nil)
|
||||
s.router.ServeHTTP(w, req)
|
||||
|
||||
assert.Equal(s.T(), http.StatusOK, w.Code)
|
||||
assert.JSONEq(s.T(), `{"assistant":null}`, w.Body.String())
|
||||
}
|
||||
|
||||
func (s *ConversationCrudTestSuite) TestInboxAssistant_ReturnsNilWhenCaptainAssistantSoftDeleted() {
|
||||
assistant := &model.CaptainAssistant{AccountID: s.testAccount.ID, Name: "Deleted Assistant", Config: json.RawMessage(`{}`), Status: model.AssistantStatusActive}
|
||||
s.Require().NoError(s.db.Create(assistant).Error)
|
||||
s.Require().NoError(s.db.Create(&model.CaptainInbox{AccountID: s.testAccount.ID, AssistantID: assistant.ID, InboxID: s.testInbox.ID}).Error)
|
||||
s.Require().NoError(s.db.Delete(assistant).Error)
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
req, _ := http.NewRequest("GET", s.convURL(s.testConv.ID)+"/inbox_assistant", nil)
|
||||
s.router.ServeHTTP(w, req)
|
||||
|
||||
assert.Equal(s.T(), http.StatusOK, w.Code)
|
||||
assert.JSONEq(s.T(), `{"assistant":null}`, w.Body.String())
|
||||
}
|
||||
|
||||
func (s *ConversationCrudTestSuite) TestInboxAssistant_UsesDisplayIDRoute() {
|
||||
displayID := uint(77)
|
||||
s.testConv.DisplayID = &displayID
|
||||
|
||||
+937
-957
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user