MCPcopy
hub / github.com/rilldata/rill / TestGithubDeploy

Function TestGithubDeploy

cli/cmd/deploy/deploy_test.go:140–168  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
140func 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
170func testSelfHostedDeploy(t *testing.T, adminClient *client.Client, ghClient *github.Client, adm *testcli.Fixture, token string) {
171 testmode.Expensive(t)

Callers

nothing calls this directly

Calls 12

ExpensiveFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
getGithubAuthTokenFunction · 0.85
testSelfHostedDeployFunction · 0.85
NewUserMethod · 0.80
ContextMethod · 0.65
GetMethod · 0.65
AddMethod · 0.65
UpdateUserMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected