Tier 1 (QOL), content batch: - version: `--version` now works (rootCmd.Version is set), and `go install ...@latest` reports the embedded module version instead of "dev" via a runtime/debug.ReadBuildInfo() fallback. ldflags-injected release builds still take precedence. - checks: App Store metadata length checks (name, description, keywords, promotional text) count characters with utf8.RuneCountInString, not bytes, so non-ASCII metadata is not falsely flagged as over Apple's limits. - codescan: honor an inline `// greenlight:ignore[ rule-id]` directive on the matching line or the line directly above it (bare = all rules on the line). - Tests for each. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
29 lines
753 B
Go
29 lines
753 B
Go
package cli
|
|
|
|
import "testing"
|
|
|
|
// An ldflags-injected version always wins over the build-info fallback.
|
|
func TestResolveVersionPrefersInjected(t *testing.T) {
|
|
old := appVersion
|
|
defer func() { appVersion = old }()
|
|
|
|
appVersion = "v1.2.3"
|
|
if got := resolveVersion(); got != "v1.2.3" {
|
|
t.Errorf("resolveVersion() = %q, want v1.2.3", got)
|
|
}
|
|
}
|
|
|
|
// With no injected version, resolveVersion falls back to build info (or "dev")
|
|
// but must never return an empty string.
|
|
func TestResolveVersionNeverEmpty(t *testing.T) {
|
|
old := appVersion
|
|
defer func() { appVersion = old }()
|
|
|
|
for _, v := range []string{"", "dev"} {
|
|
appVersion = v
|
|
if got := resolveVersion(); got == "" {
|
|
t.Errorf("resolveVersion() with appVersion=%q returned empty", v)
|
|
}
|
|
}
|
|
}
|