summaryrefslogtreecommitdiff
path: root/internal/utils/version_test.go
diff options
context:
space:
mode:
authorJames Elliott <james-d-elliott@users.noreply.github.com>2021-06-18 14:35:43 +1000
committerGitHub <noreply@github.com>2021-06-18 14:35:43 +1000
commit0d7b33022c659444617d15c95c3cbfc66561689b (patch)
treee06f6f06260136d18301df2bfa17b47945a5ef88 /internal/utils/version_test.go
parentef3c2faeb5a8d4ae30fa55fdaed5718e32f11364 (diff)
build: add enhanced information (#2067)
This commit adjusts the build flags to include version information in the LDFLAGS using the -X options. Additionally this makes the information recorded at build time more comprehensive. All build information can now be obtained via the `authelia build` command, and the `authelia version` command is now `authelia --version`. Lastly this adjusts the Dockerfile to utilize docker cache more effectively.
Diffstat (limited to 'internal/utils/version_test.go')
-rw-r--r--internal/utils/version_test.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/internal/utils/version_test.go b/internal/utils/version_test.go
new file mode 100644
index 000000000..3b8aed08a
--- /dev/null
+++ b/internal/utils/version_test.go
@@ -0,0 +1,41 @@
+package utils
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestVersionDefault(t *testing.T) {
+ v := Version()
+
+ assert.Equal(t, "untagged-unknown-dirty (master, unknown)", v)
+}
+
+func TestVersion(t *testing.T) {
+ var v string
+
+ v = version("v4.90.0", "tagged clean", "50d8b4a941c26b89482c94ab324b5a274f9ced66", "master", "")
+ assert.Equal(t, "v4.90.0", v)
+
+ v = version("v4.90.0", "tagged clean", "50d8b4a941c26b89482c94ab324b5a274f9ced66", "master", "freshports")
+ assert.Equal(t, "v4.90.0-freshports", v)
+
+ v = version("v4.90.0", "tagged dirty", "50d8b4a941c26b89482c94ab324b5a274f9ced66", "master", "")
+ assert.Equal(t, "v4.90.0-dirty", v)
+
+ v = version("v4.90.0", "untagged dirty", "50d8b4a941c26b89482c94ab324b5a274f9ced66", "master", "")
+ assert.Equal(t, "untagged-v4.90.0-dirty (master, 50d8b4a)", v)
+
+ v = version("v4.90.0", "untagged clean", "50d8b4a941c26b89482c94ab324b5a274f9ced66", "master", "")
+ assert.Equal(t, "untagged-v4.90.0 (master, 50d8b4a)", v)
+
+ v = version("v4.90.0", "untagged clean", "50d8b4a941c26b89482c94ab324b5a274f9ced66", "master", "freshports")
+ assert.Equal(t, "untagged-v4.90.0-freshports (master, 50d8b4a)", v)
+
+ v = version("v4.90.0", "untagged clean", "", "master", "")
+ assert.Equal(t, "untagged-v4.90.0 (master, unknown)", v)
+
+ v = version("v4.90.0", "", "50d8b4a941c26b89482c94ab324b5a274f9ced66", "master", "")
+ assert.Equal(t, "untagged-v4.90.0-dirty (master, 50d8b4a)", v)
+}