MCPcopy
hub / github.com/cli/cli / checkParseResult

Function checkParseResult

internal/codespaces/ssh_test.go:126–153  ·  view source on GitHub ↗
(t *testing.T, tcase parseTestCase, gotArgs, gotCmd []string, gotErr error)

Source from the content-addressed store, hash-verified

124}
125
126func checkParseResult(t *testing.T, tcase parseTestCase, gotArgs, gotCmd []string, gotErr error) {
127 if tcase.Error != "" {
128 if gotErr == nil {
129 t.Errorf("expected error and got nil: %#v", tcase)
130 }
131
132 if gotErr.Error() != tcase.Error {
133 t.Errorf("error does not match expected error, got: '%s', expected: '%s'", gotErr.Error(), tcase.Error)
134 }
135
136 return
137 }
138
139 if gotErr != nil {
140 t.Errorf("unexpected error: %v on test case: %#v", gotErr, tcase)
141 return
142 }
143
144 argsStr, parsedArgsStr := fmt.Sprintf("%s", gotArgs), fmt.Sprintf("%s", tcase.ParsedArgs)
145 if argsStr != parsedArgsStr {
146 t.Errorf("args do not match parsed args. got: '%s', expected: '%s'", argsStr, parsedArgsStr)
147 }
148
149 commandStr, parsedCommandStr := fmt.Sprintf("%s", gotCmd), fmt.Sprintf("%s", tcase.Command)
150 if commandStr != parsedCommandStr {
151 t.Errorf("command does not match parsed command. got: '%s', expected: '%s'", commandStr, parsedCommandStr)
152 }
153}

Callers 2

TestParseSSHArgsFunction · 0.85
TestParseSCPArgsFunction · 0.85

Calls 2

ErrorfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected