MCPcopy Index your code
hub / github.com/apache/devlake / ConnectRemoteServer

Function ConnectRemoteServer

backend/test/helper/client.go:108–132  ·  view source on GitHub ↗

ConnectRemoteServer returns a client to an existing server based on the config

(t *testing.T, clientConfig *RemoteClientConfig)

Source from the content-addressed store, hash-verified

106
107// ConnectRemoteServer returns a client to an existing server based on the config
108func ConnectRemoteServer(t *testing.T, clientConfig *RemoteClientConfig) *DevlakeClient {
109 var db *gorm.DB
110 var err errors.Error
111 logger := logruslog.Global.Nested("test")
112 cfg := config.GetConfig()
113 if clientConfig.DbURL != "" {
114 cfg.Set("DB_URL", clientConfig.DbURL)
115 db, err = runner.NewGormDb(cfg, logger)
116 require.NoError(t, err)
117 }
118 logger.Info("Connecting to remote server: %s", clientConfig.Endpoint)
119 client := &DevlakeClient{
120 isRemote: true,
121 Endpoint: clientConfig.Endpoint,
122 db: db,
123 cfg: cfg,
124 log: logger,
125 testCtx: t,
126 basicRes: contextimpl.NewDefaultBasicRes(cfg, logger, dalgorm.NewDalgorm(db)),
127 }
128 client.prepareDB(&LocalClientConfig{
129 TruncateDb: clientConfig.TruncateDb,
130 })
131 return client
132}
133
134// ConnectLocalServer spins up a local server from the config and returns a client connected to it
135func ConnectLocalServer(t *testing.T, clientConfig *LocalClientConfig) *DevlakeClient {

Callers 1

ConnectDevLakeServerFunction · 0.85

Calls 4

prepareDBMethod · 0.95
NestedMethod · 0.65
GetConfigMethod · 0.65
InfoMethod · 0.65

Tested by

no test coverage detected