MCPcopy Index your code
hub / github.com/cli/cli / TestPushDefault

Function TestPushDefault

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

Source from the content-addressed store, hash-verified

2098}
2099
2100func TestPushDefault(t *testing.T) {
2101 t.Run("it parses valid values correctly", func(t *testing.T) {
2102 t.Parallel()
2103
2104 tests := []struct {
2105 value string
2106 expectedPushDefault PushDefault
2107 }{
2108 {"nothing", PushDefaultNothing},
2109 {"current", PushDefaultCurrent},
2110 {"upstream", PushDefaultUpstream},
2111 {"tracking", PushDefaultTracking},
2112 {"simple", PushDefaultSimple},
2113 {"matching", PushDefaultMatching},
2114 }
2115
2116 for _, test := range tests {
2117 t.Run(test.value, func(t *testing.T) {
2118 t.Parallel()
2119
2120 pushDefault, err := ParsePushDefault(test.value)
2121 require.NoError(t, err)
2122 assert.Equal(t, test.expectedPushDefault, pushDefault)
2123 })
2124 }
2125 })
2126
2127 t.Run("it returns an error for invalid values", func(t *testing.T) {
2128 t.Parallel()
2129
2130 _, err := ParsePushDefault("invalid")
2131 require.Error(t, err)
2132 })
2133}
2134
2135func createCommandContext(t *testing.T, exitStatus int, stdout, stderr string) (*exec.Cmd, commandCtx) {
2136 cmd := exec.CommandContext(context.Background(), os.Args[0], "-test.run=TestHelperProcess", "--")

Callers

nothing calls this directly

Calls 4

ParsePushDefaultFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected