mirror of
https://github.com/grafana/alloy.git
synced 2025-11-05 13:28:02 +08:00
Currently, if Alloy was built without setting build information, it reports its version as "v0.0.0". This commit adds using the VERSION file as fallback, so if the version information wasn't present (such as when ussing `go run .`), the reported version is taken from the VERSION file at the root of the repository. The version reported is then appended with `-devel` to indicate that it is not the final release. For example, as the VERSION file currently contains `v1.1.0`, then the fallback reported version will be `v1.1.0-devel`.
21 lines
325 B
Go
21 lines
325 B
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func Test_fallbackVersionFromText(t *testing.T) {
|
|
in := `# This is a comment
|
|
# This is another comment
|
|
|
|
v1.2.3
|
|
|
|
This line is ignored!`
|
|
expect := "v1.2.3-devel"
|
|
|
|
actual := fallbackVersionFromText([]byte(in))
|
|
require.Equal(t, expect, actual)
|
|
}
|