test(knowledge): unbreak service test package after tag-loading change

Fixing the knowledge_create_test compile error in this branch let the
internal/application/service test package run for the first time, which
exposed two latent failures introduced when GetKnowledgeByID started
eagerly loading tags:

- GetOwningKBCreatorID went through the service-level GetKnowledgeByID
  (which now calls repo.GetKnowledgeTags); ownership resolution only
  needs the knowledge -> kb_id link, so resolve via repo.GetKnowledgeByID
  directly (tenant-scoped) and drop the extra tag query.
- createKnowledgeFileRepoStub lacked GetKnowledgeTags, which the create
  path always invokes via setAndAttachKnowledgeTags; add the stub method.
This commit is contained in:
wizardchen
2026-06-29 17:41:16 +08:00
committed by lyingbug
parent d24e830c85
commit 6ad75d19fd
2 changed files with 18 additions and 1 deletions
@@ -39,6 +39,15 @@ func (r *createKnowledgeFileRepoStub) CreateKnowledge(ctx context.Context, knowl
return r.createErr
}
// GetKnowledgeTags is invoked by setAndAttachKnowledgeTags after create even
// when no tags were supplied; a fresh knowledge has none, so return empty.
func (r *createKnowledgeFileRepoStub) GetKnowledgeTags(
ctx context.Context,
knowledgeIDs []string,
) (map[string][]*types.KnowledgeTag, error) {
return map[string][]*types.KnowledgeTag{}, nil
}
type createKnowledgeFileKBServiceStub struct {
interfaces.KnowledgeBaseService