This is an automated email from the ASF dual-hosted git repository. LinkinStars pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/answer.git
commit 2cb835ae226cc9562b39907f6ae41704222ffae2 Author: seiya <[email protected]> AuthorDate: Thu Oct 15 13:08:59 2026 +0000 test: expose swallowed similar question lookup error Co-Authored-By: codex <[email protected]> --- internal/service/content/question_service_test.go | 53 +++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/internal/service/content/question_service_test.go b/internal/service/content/question_service_test.go new file mode 100644 index 00000000..d688c48f --- /dev/null +++ b/internal/service/content/question_service_test.go @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package content + +import ( + "context" + "errors" + "testing" + + "github.com/apache/answer/internal/entity" + questioncommon "github.com/apache/answer/internal/service/question_common" +) + +type similarQuestionErrorRepo struct { + questioncommon.QuestionRepo + err error +} + +func (r *similarQuestionErrorRepo) GetQuestion(context.Context, string) (*entity.Question, bool, error) { + return nil, false, r.err +} + +func TestSimilarQuestionPropagatesInfoError(t *testing.T) { + wantErr := errors.New("question lookup failed") + repo := &similarQuestionErrorRepo{err: wantErr} + service := &QuestionService{ + questioncommon: questioncommon.NewQuestionCommon( + repo, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, + ), + } + + _, _, err := service.SimilarQuestion(context.Background(), "1", "viewer") + if !errors.Is(err, wantErr) { + t.Fatalf("SimilarQuestion() error = %v, want %v", err, wantErr) + } +}
