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

Function TestPushDefault

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

Source from the content-addressed store, hash-verified

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