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

Function TestParseCloneArgs

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

Source from the content-addressed store, hash-verified

1459}
1460
1461func TestParseCloneArgs(t *testing.T) {
1462 type wanted struct {
1463 args []string
1464 dir string
1465 }
1466 tests := []struct {
1467 name string
1468 args []string
1469 want wanted
1470 }{
1471 {
1472 name: "args and target",
1473 args: []string{"target_directory", "-o", "upstream", "--depth", "1"},
1474 want: wanted{
1475 args: []string{"-o", "upstream", "--depth", "1"},
1476 dir: "target_directory",
1477 },
1478 },
1479 {
1480 name: "only args",
1481 args: []string{"-o", "upstream", "--depth", "1"},
1482 want: wanted{
1483 args: []string{"-o", "upstream", "--depth", "1"},
1484 dir: "",
1485 },
1486 },
1487 {
1488 name: "only target",
1489 args: []string{"target_directory"},
1490 want: wanted{
1491 args: []string{},
1492 dir: "target_directory",
1493 },
1494 },
1495 {
1496 name: "no args",
1497 args: []string{},
1498 want: wanted{
1499 args: []string{},
1500 dir: "",
1501 },
1502 },
1503 }
1504 for _, tt := range tests {
1505 t.Run(tt.name, func(t *testing.T) {
1506 // Given optional clone modifiers and a possible target directory
1507 extraArgs := tt.args
1508
1509 // When clone arguments are separated from the target
1510 args, dir := parseCloneArgs(extraArgs)
1511 got := wanted{args: args, dir: dir}
1512
1513 // Then modifiers stay ordered and a leading target is returned separately
1514 assert.Equal(t, tt.want, got)
1515 })
1516 }
1517}
1518

Callers

nothing calls this directly

Calls 3

parseCloneArgsFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected