MCPcopy
hub / github.com/cli/cli / stubLocalExtension

Function stubLocalExtension

pkg/cmd/extension/manager_test.go:1469–1495  ·  view source on GitHub ↗
(tempDir, path string)

Source from the content-addressed store, hash-verified

1467}
1468
1469func stubLocalExtension(tempDir, path string) error {
1470 extDir, err := os.MkdirTemp(tempDir, "local-ext")
1471 if err != nil {
1472 return err
1473 }
1474 extFile, err := os.OpenFile(filepath.Join(extDir, filepath.Base(path)), os.O_CREATE, 0755)
1475 if err != nil {
1476 return err
1477 }
1478 if err := extFile.Close(); err != nil {
1479 return err
1480 }
1481
1482 linkPath := filepath.Dir(path)
1483 if err := os.MkdirAll(filepath.Dir(linkPath), 0755); err != nil {
1484 return err
1485 }
1486 f, err := os.OpenFile(linkPath, os.O_WRONLY|os.O_CREATE, 0644)
1487 if err != nil {
1488 return err
1489 }
1490 _, err = f.WriteString(extDir)
1491 if err != nil {
1492 return err
1493 }
1494 return f.Close()
1495}
1496
1497// Given the path where an extension should be installed and a manifest struct, creates a fake binary extension on disk
1498func stubBinaryExtension(installPath string, bm binManifest) error {

Calls 3

JoinMethod · 0.80
BaseMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected