MCPcopy Index your code
hub / github.com/git-bug/git-bug / TestGitlabPushPull

Function TestGitlabPushPull

bridge/gitlab/export_test.go:140–281  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

138}
139
140func TestGitlabPushPull(t *testing.T) {
141 // token must have 'repo' and 'delete_repo' scopes
142 envToken := os.Getenv("GITLAB_API_TOKEN")
143 if envToken == "" {
144 t.Skip("Env var GITLAB_API_TOKEN missing")
145 }
146
147 // create repo backend
148 repo := repository.CreateGoGitTestRepo(t, false)
149
150 backend, err := cache.NewRepoCacheNoEvents(repo)
151 require.NoError(t, err)
152
153 // set author identity
154 login := "test-identity"
155 author, err := backend.Identities().New("test identity", "test@test.org")
156 require.NoError(t, err)
157 author.SetMetadata(metaKeyGitlabLogin, login)
158 err = author.Commit()
159 require.NoError(t, err)
160
161 err = backend.SetUserIdentity(author)
162 require.NoError(t, err)
163
164 defer backend.Close()
165 interrupt.RegisterCleaner(backend.Close)
166
167 token := auth.NewToken(target, envToken)
168 token.SetMetadata(auth.MetaKeyLogin, login)
169 token.SetMetadata(auth.MetaKeyBaseURL, defaultBaseURL)
170 err = auth.Store(repo, token)
171 require.NoError(t, err)
172
173 tests := testCases(t, backend)
174
175 // generate project name
176 projectName := generateRepoName()
177
178 // create target Gitlab repository
179 projectID, err := createRepository(context.TODO(), projectName, token)
180 require.NoError(t, err)
181
182 fmt.Printf("created project: %s (%d)\n", projectName, projectID)
183
184 // Make sure to remove the Gitlab repository when the test end
185 defer func(t *testing.T) {
186 if err := deleteRepository(context.TODO(), projectID, token); err != nil {
187 t.Fatal(err)
188 }
189 fmt.Printf("deleted repository: %s (%d)\n", projectName, projectID)
190 }(t)
191
192 interrupt.RegisterCleaner(func() error {
193 return deleteRepository(context.TODO(), projectID, token)
194 })
195
196 ctx := context.Background()
197

Callers

nothing calls this directly

Calls 15

InitMethod · 0.95
ExportAllMethod · 0.95
InitMethod · 0.95
ImportAllMethod · 0.95
CreateGoGitTestRepoFunction · 0.92
NewRepoCacheNoEventsFunction · 0.92
RegisterCleanerFunction · 0.92
NewTokenFunction · 0.92
StoreFunction · 0.92
IdentitiesMethod · 0.80
SetUserIdentityMethod · 0.80
FatalMethod · 0.80

Tested by

no test coverage detected