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

Function stubLocalExtension

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

Source from the content-addressed store, hash-verified

1543}
1544
1545func stubLocalExtension(tempDir, path string) error {
1546 extDir, err := os.MkdirTemp(tempDir, "local-ext")
1547 if err != nil {
1548 return err
1549 }
1550 extFile, err := os.OpenFile(filepath.Join(extDir, filepath.Base(path)), os.O_CREATE, 0755)
1551 if err != nil {
1552 return err
1553 }
1554 if err := extFile.Close(); err != nil {
1555 return err
1556 }
1557
1558 linkPath := filepath.Dir(path)
1559 if err := os.MkdirAll(filepath.Dir(linkPath), 0755); err != nil {
1560 return err
1561 }
1562 f, err := os.OpenFile(linkPath, os.O_WRONLY|os.O_CREATE, 0644)
1563 if err != nil {
1564 return err
1565 }
1566 _, err = f.WriteString(extDir)
1567 if err != nil {
1568 return err
1569 }
1570 return f.Close()
1571}
1572
1573// Given the path where an extension should be installed and a manifest struct, creates a fake binary extension on disk
1574func stubBinaryExtension(installPath string, bm binManifest) error {

Calls 3

JoinMethod · 0.80
BaseMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected