1
0
mirror of https://github.com/Jguer/yay.git synced 2026-04-07 14:51:13 +02:00
yay/pkg/text/utils_coverage_test.go
Jo 3b79933638
test: harden coverage and make tests parallel-safe (#2797)
* Test coverage hardening and parallel-safe refactors

Add focused test coverage for under-tested operational paths, edge branches,
and make key table-driven suites parallel-safe. Also fixed flaky installer
test execution under repeated/parallel runs.

* chore: fix goimports ordering for golangci-lint

* Test(download): expand integration coverage for download paths

Add integration scenarios for force/pull repo updates, repo-only and skip semantics,
and direct AUR download/scanner coverage used by getpkgbuild and package preparation.

* Test(exe): relax systemd-run path assertion

Fix flaky TestBuildGitCmd by accepting an absolute systemd-run path while still
asserting the expected binary is used.

* Test(text): avoid race in color tests

Remove parallel execution from TestColorHash so global UseColor writes do not
overlap with color consumers in parallel tests and trigger race detector
failures.

* fix potential race conditions
2026-03-25 00:51:34 +01:00

38 lines
744 B
Go

//go:build !integration
// +build !integration
package text
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestSplitDBFromName(t *testing.T) {
t.Parallel()
db, pkg := SplitDBFromName("core/pkg")
require.Equal(t, "core", db)
require.Equal(t, "pkg", pkg)
db, pkg = SplitDBFromName("pkg")
require.Equal(t, "", db)
require.Equal(t, "pkg", pkg)
}
func TestCreateOSC8Link(t *testing.T) {
t.Parallel()
got := CreateOSC8Link("https://example.com", "text")
require.Equal(t, "\033]8;;https://example.com\033\\text\033]8;;\033\\", got)
}
func TestHumanReadable(t *testing.T) {
t.Parallel()
require.Equal(t, "10.0 B", Human(10))
require.Equal(t, "1.0 KiB", Human(1024))
require.Equal(t, "1.5 KiB", Human(1536))
}