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

Function TestPushDefault

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

Source from the content-addressed store, hash-verified

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