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)
| 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. |
| 303 | func 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. |
| 325 | type mockGithub struct{} |
no test coverage detected