(t *testing.T)
| 1319 | } |
| 1320 | |
| 1321 | func 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 | |
| 1341 | func TestClientPushReportsMissingRemote(t *testing.T) { |
| 1342 | // Given a repository with a local trunk commit but no remote |
nothing calls this directly
no test coverage detected