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

Function Test_parseBranchConfig

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

Source from the content-addressed store, hash-verified

808}
809
810func 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 },

Callers

nothing calls this directly

Calls 3

parseBranchConfigFunction · 0.85
RunMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected