(t *testing.T)
| 808 | } |
| 809 | |
| 810 | func Test_parseBranchConfig(t *testing.T) { |
| 811 | tests := []struct { |
| 812 | name string |
| 813 | configLines []string |
| 814 | wantBranchConfig BranchConfig |
| 815 | }{ |
| 816 | { |
| 817 | name: "remote branch", |
| 818 | configLines: []string{"branch.trunk.remote origin"}, |
| 819 | wantBranchConfig: BranchConfig{ |
| 820 | RemoteName: "origin", |
| 821 | }, |
| 822 | }, |
| 823 | { |
| 824 | name: "merge ref", |
| 825 | configLines: []string{"branch.trunk.merge refs/heads/trunk"}, |
| 826 | wantBranchConfig: BranchConfig{ |
| 827 | MergeRef: "refs/heads/trunk", |
| 828 | }, |
| 829 | }, |
| 830 | { |
| 831 | name: "merge base", |
| 832 | configLines: []string{"branch.trunk.gh-merge-base gh-merge-base"}, |
| 833 | wantBranchConfig: BranchConfig{ |
| 834 | MergeBase: "gh-merge-base", |
| 835 | }, |
| 836 | }, |
| 837 | { |
| 838 | name: "pushremote", |
| 839 | configLines: []string{"branch.trunk.pushremote pushremote"}, |
| 840 | wantBranchConfig: BranchConfig{ |
| 841 | PushRemoteName: "pushremote", |
| 842 | }, |
| 843 | }, |
| 844 | { |
| 845 | name: "remote and pushremote are specified by name", |
| 846 | configLines: []string{ |
| 847 | "branch.trunk.remote upstream", |
| 848 | "branch.trunk.pushremote origin", |
| 849 | }, |
| 850 | wantBranchConfig: BranchConfig{ |
| 851 | RemoteName: "upstream", |
| 852 | PushRemoteName: "origin", |
| 853 | }, |
| 854 | }, |
| 855 | { |
| 856 | name: "remote and pushremote are specified by url", |
| 857 | configLines: []string{ |
| 858 | "branch.trunk.remote git@github.com:UPSTREAMOWNER/REPO.git", |
| 859 | "branch.trunk.pushremote git@github.com:ORIGINOWNER/REPO.git", |
| 860 | }, |
| 861 | wantBranchConfig: BranchConfig{ |
| 862 | RemoteURL: &url.URL{ |
| 863 | Scheme: "ssh", |
| 864 | User: url.User("git"), |
| 865 | Host: "github.com", |
| 866 | Path: "/UPSTREAMOWNER/REPO.git", |
| 867 | }, |
nothing calls this directly
no test coverage detected