MCPcopy Index your code
hub / github.com/rilldata/rill / newGithub

Function newGithub

admin/testadmin/testadmin.go:303–322  ·  view source on GitHub ↗

newGithub creates a new Github client. In short testing mode this is a mock client which has no-op implementations of all methods. Otherwise it creates a real implementation that makes real API calls to Github.

(t *testing.T)

Source from the content-addressed store, hash-verified

301// newGithub creates a new Github client. In short testing mode this is a mock client which has no-op implementations of all methods.
302// Otherwise it creates a real implementation that makes real API calls to Github.
303func newGithub(t *testing.T) admin.Github {
304 if testing.Short() {
305 return &mockGithub{}
306 }
307
308 _, currentFile, _, _ := goruntime.Caller(0)
309 envPath := filepath.Join(currentFile, "..", "..", "..", ".env")
310 _, err := os.Stat(envPath)
311 if err == nil {
312 err := godotenv.Load(envPath)
313 require.NoError(t, err)
314 }
315
316 githubAppID, err := strconv.ParseInt(os.Getenv("RILL_ADMIN_TEST_GITHUB_APP_ID"), 10, 64)
317 require.NoError(t, err)
318
319 github, err := admin.NewGithub(t.Context(), githubAppID, os.Getenv("RILL_ADMIN_TEST_GITHUB_APP_PRIVATE_KEY"), os.Getenv("RILL_ADMIN_TEST_GITHUB_MANAGED_ACCOUNT"), zap.Must(zap.NewDevelopment()))
320 require.NoError(t, err)
321 return github
322}
323
324// mockGithub provides a mock implementation of admin.Github.
325type mockGithub struct{}

Callers 1

NewWithOptionalRuntimeFunction · 0.85

Calls 3

NewGithubFunction · 0.92
StatMethod · 0.65
ContextMethod · 0.65

Tested by

no test coverage detected