mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
* feat: Add separate package manager and resolver * fix: Npm dependency resolver * feat: Add analyzer for malysis query * feat: Add package manager guard as the orchestrator * feat: Add PMG to orchestrate installation * Add concurrent scan execution * Introduce package manager interaction abstraction * feat: Add UI port for guard * Remove refactored source files * Update README * fix: CI script for multi-arch build * ci: goreleaser CI fix * fix: npm command parser to extract package names * feat: Introduce global config primitive * fix: Close results channel for clean goroutine exit * ci: Add container image releaser * test: Improve test for npm resolver * refactor: Analyzer to generalise * Improve UI with additional info * fix: Goreleaser config * fix: npm resolver bug * fix: Fail when command exec workflow fails * fix: Bug with transitive dependency resolution * fix: Synchronize common data update in dependency resolver * chore: Improve log handling * docs: Update README * fix: UI text wrapping * fix: UI handling bugs * feat: Use concurrent dependency resolver
80 lines
1.7 KiB
Go
80 lines
1.7 KiB
Go
package ui
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
// TestTermWidthFormatText is exported for testing
|
|
func TestTermWidthFormatTextFunc(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
text string
|
|
maxWidth int
|
|
expected string
|
|
}{
|
|
{
|
|
name: "empty string",
|
|
text: "",
|
|
maxWidth: 10,
|
|
expected: "",
|
|
},
|
|
{
|
|
name: "single word less than max width",
|
|
text: "hello",
|
|
maxWidth: 10,
|
|
expected: "hello",
|
|
},
|
|
{
|
|
name: "single word longer than max width",
|
|
text: "supercalifragilisticexpialidocious",
|
|
maxWidth: 10,
|
|
expected: "supercalifragilisticexpialidocious",
|
|
},
|
|
{
|
|
name: "multiple words on single line",
|
|
text: "hello world",
|
|
maxWidth: 20,
|
|
expected: "hello world",
|
|
},
|
|
{
|
|
name: "multiple words wrapped to multiple lines",
|
|
text: "The quick brown fox jumps over the lazy dog",
|
|
maxWidth: 20,
|
|
expected: "The quick brown fox\njumps over the lazy\ndog",
|
|
},
|
|
{
|
|
name: "text with existing newlines",
|
|
text: "hello\nworld",
|
|
maxWidth: 20,
|
|
expected: "hello world",
|
|
},
|
|
{
|
|
name: "text with multiple spaces",
|
|
text: "hello world test",
|
|
maxWidth: 20,
|
|
expected: "hello world test",
|
|
},
|
|
{
|
|
name: "very small max width",
|
|
text: "hello world",
|
|
maxWidth: 3,
|
|
expected: "hello\nworld",
|
|
},
|
|
{
|
|
name: "large max width",
|
|
text: "The quick brown fox jumps over the lazy dog",
|
|
maxWidth: 100,
|
|
expected: "The quick brown fox jumps over the lazy dog",
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
result := termWidthFormatText(tt.text, tt.maxWidth)
|
|
if result != tt.expected {
|
|
t.Errorf("termWidthFormatText() = %q, want %q", result, tt.expected)
|
|
}
|
|
})
|
|
}
|
|
}
|