feat: 系统性改进后端测试体系
- 新增 6 个测试场景 (config load pipe, handler errors, service aggregation, engine degradation, openai decoder edges, negative tests) - 更新测试工具规格 (mockgen, in-memory SQLite) - 覆盖率目标从 >80% 提升至 >85% - 新增 test-unit 和 test-integration Makefile 命令 - 新增死代码清理和 mockgen 需求 - 归档变更至 openspec/changes/archive/2026-04-22-improve-backend-testing/
This commit is contained in:
56
backend/tests/mocks/mock_routing_service.go
Normal file
56
backend/tests/mocks/mock_routing_service.go
Normal file
@@ -0,0 +1,56 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: routing_service.go
|
||||
//
|
||||
// Generated by this command:
|
||||
//
|
||||
// mockgen -source=routing_service.go -destination=../../tests/mocks/mock_routing_service.go -package=mocks
|
||||
//
|
||||
|
||||
// Package mocks is a generated GoMock package.
|
||||
package mocks
|
||||
|
||||
import (
|
||||
domain "nex/backend/internal/domain"
|
||||
reflect "reflect"
|
||||
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
// MockRoutingService is a mock of RoutingService interface.
|
||||
type MockRoutingService struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockRoutingServiceMockRecorder
|
||||
isgomock struct{}
|
||||
}
|
||||
|
||||
// MockRoutingServiceMockRecorder is the mock recorder for MockRoutingService.
|
||||
type MockRoutingServiceMockRecorder struct {
|
||||
mock *MockRoutingService
|
||||
}
|
||||
|
||||
// NewMockRoutingService creates a new mock instance.
|
||||
func NewMockRoutingService(ctrl *gomock.Controller) *MockRoutingService {
|
||||
mock := &MockRoutingService{ctrl: ctrl}
|
||||
mock.recorder = &MockRoutingServiceMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockRoutingService) EXPECT() *MockRoutingServiceMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// RouteByModelName mocks base method.
|
||||
func (m *MockRoutingService) RouteByModelName(providerID, modelName string) (*domain.RouteResult, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "RouteByModelName", providerID, modelName)
|
||||
ret0, _ := ret[0].(*domain.RouteResult)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// RouteByModelName indicates an expected call of RouteByModelName.
|
||||
func (mr *MockRoutingServiceMockRecorder) RouteByModelName(providerID, modelName any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RouteByModelName", reflect.TypeOf((*MockRoutingService)(nil).RouteByModelName), providerID, modelName)
|
||||
}
|
||||
Reference in New Issue
Block a user