## Summary - Extract PHP/Laravel commands to `core/php` repo (42 files, standalone module) - Extract CI/release + SDK commands to `core/ci` repo (10 files) - Remove `internal/variants/` build tag system entirely - Move all 30 remaining command packages from `internal/cmd/` to top-level `cmd/` - Rewrite `main.go` with direct imports — no more variant selection - PHP and CI are now optional via commented import lines in main.go Co-authored-by: Claude <developers@lethean.io> Reviewed-on: #2 Co-authored-by: Charon <charon@lthn.ai> Co-committed-by: Charon <charon@lthn.ai>
52 lines
1.6 KiB
Go
52 lines
1.6 KiB
Go
package testcmd
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestShortenPackageName(t *testing.T) {
|
|
assert.Equal(t, "pkg/foo", shortenPackageName("forge.lthn.ai/core/go/pkg/foo"))
|
|
assert.Equal(t, "cli-php", shortenPackageName("forge.lthn.ai/core/cli-php"))
|
|
assert.Equal(t, "bar", shortenPackageName("github.com/other/bar"))
|
|
}
|
|
|
|
func TestFormatCoverageTest(t *testing.T) {
|
|
assert.Contains(t, formatCoverage(85.0), "85.0%")
|
|
assert.Contains(t, formatCoverage(65.0), "65.0%")
|
|
assert.Contains(t, formatCoverage(25.0), "25.0%")
|
|
}
|
|
|
|
func TestParseTestOutput(t *testing.T) {
|
|
output := `ok forge.lthn.ai/core/go/pkg/foo 0.100s coverage: 50.0% of statements
|
|
FAIL forge.lthn.ai/core/go/pkg/bar
|
|
? forge.lthn.ai/core/go/pkg/baz [no test files]
|
|
`
|
|
results := parseTestOutput(output)
|
|
assert.Equal(t, 1, results.passed)
|
|
assert.Equal(t, 1, results.failed)
|
|
assert.Equal(t, 1, results.skipped)
|
|
assert.Equal(t, 1, len(results.failedPkgs))
|
|
assert.Equal(t, "forge.lthn.ai/core/go/pkg/bar", results.failedPkgs[0])
|
|
assert.Equal(t, 1, len(results.packages))
|
|
assert.Equal(t, 50.0, results.packages[0].coverage)
|
|
}
|
|
|
|
func TestPrintCoverageSummarySafe(t *testing.T) {
|
|
// This tests the bug fix for long package names causing negative Repeat count
|
|
results := testResults{
|
|
packages: []packageCoverage{
|
|
{name: "forge.lthn.ai/core/go/pkg/short", coverage: 100, hasCov: true},
|
|
{name: "forge.lthn.ai/core/go/pkg/a-very-very-very-very-very-long-package-name-that-might-cause-issues", coverage: 80, hasCov: true},
|
|
},
|
|
passed: 2,
|
|
totalCov: 180,
|
|
covCount: 2,
|
|
}
|
|
|
|
// Should not panic
|
|
assert.NotPanics(t, func() {
|
|
printCoverageSummary(results)
|
|
})
|
|
}
|