MCPcopy Create free account
hub / github.com/GoSimplicity/LinkMe / createMockElasticsearchClient

Function createMockElasticsearchClient

internal/repository/search_test.go:21–33  ·  view source on GitHub ↗

辅助函数,用于创建一个模拟的Elasticsearch客户端,便于测试

()

Source from the content-addressed store, hash-verified

19
20// 辅助函数,用于创建一个模拟的Elasticsearch客户端,便于测试
21func createMockElasticsearchClient() *elasticsearch.TypedClient {
22 addr := os.Getenv("LINKME_ES_ADDR")
23 if addr == "" {
24 addr = "http://localhost:19200"
25 }
26 client, err := elasticsearch.NewTypedClient(elasticsearch.Config{
27 Addresses: []string{addr},
28 })
29 if err != nil {
30 panic(err)
31 }
32 return client
33}
34
35// 辅助函数,用于创建一个模拟的GORM数据库实例,这里简单返回nil,根据实际情况可进一步完善模拟逻辑
36func createMockGormDB() *gorm.DB {

Callers 3

TestCreatePostIndexFunction · 0.85
TestSearchPostsFunction · 0.85
TestSearchUsersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected