[client, management, misc] expose VCS revision in dev build version output (#6263)

* Refactor to use a common checker for development version

* Adds commit sha to development version for cobra command only

Leave dashboard unaffected

* Adjust for "v0.31.1-dev" test case

which must be considered pre-release

* Drop synthetic "dev"/"0.50.0-dev" firewall feature-gate fixtures

These test cases encoded the loose strings.Contains(v, "dev")
semantics inherited from peerSupportedFirewallFeatures, but
NetbirdVersion() never produces those values — only the literal
"development" (and now "development-<sha>[-dirty]") ever flows
through the wire. The agent owns the semantics of an ephemeral
development build, so the tests should exercise the strings we
actually emit.

Replaced with development, development-<sha> and
development-<sha>-dirty cases that match the HasPrefix("development")
predicate introduced upstream.

* Remove unexistent tests on wire format

The sha / dirty flag are added only when the CLI asks the version.
Account versions is unaffacted and can only strictly match "development"

* Adds tests for IsDevelopmentVersion
This commit is contained in:
Riccardo Manfrin
2026-06-03 08:56:50 +02:00
committed by GitHub
parent fa1e241aea
commit 2b57a7d43b
9 changed files with 102 additions and 45 deletions
+26
View File
@@ -0,0 +1,26 @@
package version
import "testing"
func TestIsDevelopmentVersion(t *testing.T) {
tests := []struct {
version string
want bool
}{
{"development", true},
{"development-0823f3ff9ab1", true},
{"development-0823f3ff9ab1-dirty", true},
{"0.50.0", false},
{"v0.31.1-dev", false},
{"1.0.0-dev", false},
{"dev", false},
{"", false},
}
for _, tt := range tests {
t.Run(tt.version, func(t *testing.T) {
if got := IsDevelopmentVersion(tt.version); got != tt.want {
t.Errorf("IsDevelopmentVersion(%q) = %v, want %v", tt.version, got, tt.want)
}
})
}
}