Merge pull request '[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/cli/RFC.md fully. Find ONE feature ...' (#25) from agent/update-the-code-against-the-ax-design-pr into dev
Some checks failed
Security Scan / security (push) Has been cancelled
Some checks failed
Security Scan / security (push) Has been cancelled
This commit is contained in:
commit
a79db9a8ca
2 changed files with 46 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"forge.lthn.ai/core/go-cache"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
@ -248,3 +249,44 @@ func TestRenderPkgSearchResults_ShowsMetadata(t *testing.T) {
|
||||||
assert.Contains(t, out, "Go")
|
assert.Contains(t, out, "Go")
|
||||||
assert.Contains(t, out, "updated 2h ago")
|
assert.Contains(t, out, "updated 2h ago")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRunPkgSearch_RespectsLimitWithCachedResults(t *testing.T) {
|
||||||
|
tmp := t.TempDir()
|
||||||
|
writeTestRegistry(t, tmp)
|
||||||
|
withWorkingDir(t, tmp)
|
||||||
|
|
||||||
|
c, err := cache.New(nil, filepath.Join(tmp, ".core", "cache"), 0)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NoError(t, c.Set(cache.GitHubReposKey("host-uk"), []ghRepo{
|
||||||
|
{
|
||||||
|
FullName: "host-uk/core-alpha",
|
||||||
|
Name: "core-alpha",
|
||||||
|
Description: "Alpha package",
|
||||||
|
Visibility: "public",
|
||||||
|
UpdatedAt: time.Now().Add(-time.Hour).Format(time.RFC3339),
|
||||||
|
StargazerCount: 1,
|
||||||
|
PrimaryLanguage: ghLanguage{
|
||||||
|
Name: "Go",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
FullName: "host-uk/core-beta",
|
||||||
|
Name: "core-beta",
|
||||||
|
Description: "Beta package",
|
||||||
|
Visibility: "public",
|
||||||
|
UpdatedAt: time.Now().Add(-2 * time.Hour).Format(time.RFC3339),
|
||||||
|
StargazerCount: 2,
|
||||||
|
PrimaryLanguage: ghLanguage{
|
||||||
|
Name: "Go",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
|
||||||
|
out := capturePkgOutput(t, func() {
|
||||||
|
err := runPkgSearch("host-uk", "*", "", 1, false, "table")
|
||||||
|
require.NoError(t, err)
|
||||||
|
})
|
||||||
|
|
||||||
|
assert.Contains(t, out, "core-alpha")
|
||||||
|
assert.NotContains(t, out, "core-beta")
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -188,6 +188,10 @@ func runPkgSearch(org, pattern, repoType string, limit int, refresh bool, format
|
||||||
return cmp.Compare(a.Name, b.Name)
|
return cmp.Compare(a.Name, b.Name)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if limit > 0 && len(filtered) > limit {
|
||||||
|
filtered = filtered[:limit]
|
||||||
|
}
|
||||||
|
|
||||||
if strings.EqualFold(format, "json") {
|
if strings.EqualFold(format, "json") {
|
||||||
report := buildPkgSearchReport(org, pattern, repoType, limit, fromCache, filtered)
|
report := buildPkgSearchReport(org, pattern, repoType, limit, fromCache, filtered)
|
||||||
return printPkgSearchJSON(report)
|
return printPkgSearchJSON(report)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue