MCPcopy Create free account
hub / github.com/cli/cli / TestClientPushCreatesRemoteBranchAndUpstream

Function TestClientPushCreatesRemoteBranchAndUpstream

git/client_test.go:1321–1339  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1319}
1320
1321func TestClientPushCreatesRemoteBranchAndUpstream(t *testing.T) {
1322 // Given a local trunk branch, an empty remote, and a client defaulting to a different repository
1323 repo := newTestRepo(t)
1324 remote := newBareTestRepo(t)
1325 wantHead := repo.commit(t, "local commit")
1326 repo.run(t, "remote", "add", "origin", remote.fileURL())
1327 defaultRepo := newTestRepo(t)
1328 defaultHead := defaultRepo.commit(t, "default repository commit")
1329 client := &Client{RepoDir: defaultRepo.dir}
1330
1331 // When trunk is pushed using a repository-directory modifier
1332 err := client.Push(t.Context(), "origin", "trunk", WithRepoDir(repo.dir))
1333
1334 // Then the remote branch is created from the target repository and configured as its upstream
1335 require.NoError(t, err)
1336 assert.Equal(t, wantHead, remote.run(t, "rev-parse", "refs/heads/trunk"))
1337 assert.Equal(t, "origin/trunk", repo.run(t, "rev-parse", "--abbrev-ref", "trunk@{upstream}"))
1338 assert.Equal(t, defaultHead, defaultRepo.run(t, "rev-parse", "HEAD"))
1339}
1340
1341func TestClientPushReportsMissingRemote(t *testing.T) {
1342 // Given a repository with a local trunk commit but no remote

Callers

nothing calls this directly

Calls 8

PushMethod · 0.95
newTestRepoFunction · 0.85
newBareTestRepoFunction · 0.85
WithRepoDirFunction · 0.85
commitMethod · 0.80
fileURLMethod · 0.80
EqualMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected