This test require gh cli to be installed on the system. Alternatively a personal access token can be set via RILL_TEST_GH_TOKEN environment variable.
(t *testing.T)
| 138 | // This test require gh cli to be installed on the system. |
| 139 | // Alternatively a personal access token can be set via RILL_TEST_GH_TOKEN environment variable. |
| 140 | func TestGithubDeploy(t *testing.T) { |
| 141 | testmode.Expensive(t) |
| 142 | personalAccessToken := getGithubAuthToken(t) |
| 143 | // github client |
| 144 | ghClient := github.NewTokenClient(t.Context(), personalAccessToken) |
| 145 | ghUser, _, err := ghClient.Users.Get(t.Context(), "") |
| 146 | require.NoError(t, err) |
| 147 | |
| 148 | // test service |
| 149 | adm := testadmin.New(t) |
| 150 | user, c := adm.NewUser(t) |
| 151 | expiry := time.Now().Add(time.Hour * 24 * 30) |
| 152 | adm.Admin.DB.UpdateUser(t.Context(), user.ID, &database.UpdateUserOptions{ |
| 153 | DisplayName: user.DisplayName, |
| 154 | PhotoURL: user.PhotoURL, |
| 155 | GithubUsername: *ghUser.Login, |
| 156 | GithubToken: personalAccessToken, |
| 157 | GithubTokenExpiresOn: &expiry, |
| 158 | }) |
| 159 | u1 := testcli.New(t, adm, c.Token) |
| 160 | |
| 161 | t.Run("self-hosted git deploy", func(t *testing.T) { |
| 162 | testSelfHostedDeploy(t, c, ghClient, u1, personalAccessToken) |
| 163 | }) |
| 164 | |
| 165 | t.Run("self-hosted git deploy with monorepo", func(t *testing.T) { |
| 166 | testSelfHostedMonorepoDeploy(t, c, ghClient, u1, personalAccessToken) |
| 167 | }) |
| 168 | } |
| 169 | |
| 170 | func testSelfHostedDeploy(t *testing.T, adminClient *client.Client, ghClient *github.Client, adm *testcli.Fixture, token string) { |
| 171 | testmode.Expensive(t) |
nothing calls this directly
no test coverage detected