(t *testing.T)
| 571 | } |
| 572 | |
| 573 | func TestParseBranchConfig(t *testing.T) { |
| 574 | tests := []struct { |
| 575 | name string |
| 576 | configLines []string |
| 577 | wantBranchConfig BranchConfig |
| 578 | }{ |
| 579 | { |
| 580 | name: "remote branch", |
| 581 | configLines: []string{"branch.trunk.remote origin"}, |
| 582 | wantBranchConfig: BranchConfig{ |
| 583 | RemoteName: "origin", |
| 584 | }, |
| 585 | }, |
| 586 | { |
| 587 | name: "merge ref", |
| 588 | configLines: []string{"branch.trunk.merge refs/heads/trunk"}, |
| 589 | wantBranchConfig: BranchConfig{ |
| 590 | MergeRef: "refs/heads/trunk", |
| 591 | }, |
| 592 | }, |
| 593 | { |
| 594 | name: "merge base", |
| 595 | configLines: []string{"branch.trunk.gh-merge-base gh-merge-base"}, |
| 596 | wantBranchConfig: BranchConfig{ |
| 597 | MergeBase: "gh-merge-base", |
| 598 | }, |
| 599 | }, |
| 600 | { |
| 601 | name: "pushremote", |
| 602 | configLines: []string{"branch.trunk.pushremote pushremote"}, |
| 603 | wantBranchConfig: BranchConfig{ |
| 604 | PushRemoteName: "pushremote", |
| 605 | }, |
| 606 | }, |
| 607 | { |
| 608 | name: "remote and pushremote are specified by name", |
| 609 | configLines: []string{ |
| 610 | "branch.trunk.remote upstream", |
| 611 | "branch.trunk.pushremote origin", |
| 612 | }, |
| 613 | wantBranchConfig: BranchConfig{ |
| 614 | RemoteName: "upstream", |
| 615 | PushRemoteName: "origin", |
| 616 | }, |
| 617 | }, |
| 618 | { |
| 619 | name: "remote and pushremote are specified by url", |
| 620 | configLines: []string{ |
| 621 | "branch.trunk.remote git@github.com:UPSTREAMOWNER/REPO.git", |
| 622 | "branch.trunk.pushremote git@github.com:ORIGINOWNER/REPO.git", |
| 623 | }, |
| 624 | wantBranchConfig: BranchConfig{ |
| 625 | RemoteURL: &url.URL{ |
| 626 | Scheme: "ssh", |
| 627 | User: url.User("git"), |
| 628 | Host: "github.com", |
| 629 | Path: "/UPSTREAMOWNER/REPO.git", |
| 630 | }, |
nothing calls this directly
no test coverage detected