* fix(docs): respect workspace.yaml packages_dir setting (fixes #46) * fix(workspace): improve config loading logic (CR feedback) - Expand ~ before resolving relative paths in cmd_registry - Handle LoadWorkspaceConfig errors properly - Update Repo.Path when PackagesDir overrides default - Validate workspace config version - Add unit tests for workspace config loading * docs: add comments and increase test coverage (CR feedback) - Add docstrings to exported functions in pkg/cli - Add unit tests for Semantic Output (pkg/cli/output.go) - Add unit tests for CheckBuilder (pkg/cli/check.go) - Add unit tests for IPC Query/Perform (pkg/framework/core) * fix(test): fix panics and failures in php package tests - Fix panic in TestLookupLinuxKit_Bad by mocking paths - Fix assertion errors in TestGetSSLDir_Bad and TestGetPackageInfo_Bad - Fix formatting in test files * fix(test): correct syntax in services_extended_test.go * fix(ci): point coverage workflow to go.mod instead of go.work * fix(ci): build CLI before running coverage * fix(ci): run go generate for updater package in coverage workflow * fix(github): allow dry-run publish without gh CLI authentication Moves validation check after dry-run check so tests can verify dry-run behavior in CI environments.
98 lines
1.4 KiB
Go
98 lines
1.4 KiB
Go
package cli
|
|
|
|
import (
|
|
"bytes"
|
|
"io"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func captureOutput(f func()) string {
|
|
old := os.Stdout
|
|
r, w, _ := os.Pipe()
|
|
os.Stdout = w
|
|
|
|
f()
|
|
|
|
w.Close()
|
|
os.Stdout = old
|
|
|
|
var buf bytes.Buffer
|
|
io.Copy(&buf, r)
|
|
return buf.String()
|
|
}
|
|
|
|
func TestSemanticOutput(t *testing.T) {
|
|
UseASCII()
|
|
|
|
// Test Success
|
|
out := captureOutput(func() {
|
|
Success("done")
|
|
})
|
|
if out == "" {
|
|
t.Error("Success output empty")
|
|
}
|
|
|
|
// Test Error
|
|
out = captureOutput(func() {
|
|
Error("fail")
|
|
})
|
|
if out == "" {
|
|
t.Error("Error output empty")
|
|
}
|
|
|
|
// Test Warn
|
|
out = captureOutput(func() {
|
|
Warn("warn")
|
|
})
|
|
if out == "" {
|
|
t.Error("Warn output empty")
|
|
}
|
|
|
|
// Test Info
|
|
out = captureOutput(func() {
|
|
Info("info")
|
|
})
|
|
if out == "" {
|
|
t.Error("Info output empty")
|
|
}
|
|
|
|
// Test Task
|
|
out = captureOutput(func() {
|
|
Task("task", "msg")
|
|
})
|
|
if out == "" {
|
|
t.Error("Task output empty")
|
|
}
|
|
|
|
// Test Section
|
|
out = captureOutput(func() {
|
|
Section("section")
|
|
})
|
|
if out == "" {
|
|
t.Error("Section output empty")
|
|
}
|
|
|
|
// Test Hint
|
|
out = captureOutput(func() {
|
|
Hint("hint", "msg")
|
|
})
|
|
if out == "" {
|
|
t.Error("Hint output empty")
|
|
}
|
|
|
|
// Test Result
|
|
out = captureOutput(func() {
|
|
Result(true, "pass")
|
|
})
|
|
if out == "" {
|
|
t.Error("Result(true) output empty")
|
|
}
|
|
|
|
out = captureOutput(func() {
|
|
Result(false, "fail")
|
|
})
|
|
if out == "" {
|
|
t.Error("Result(false) output empty")
|
|
}
|
|
}
|