Files
alloy/fallback_version_test.go
Robert Fratto 2509c15780 main: use VERSION file as fallback for version reporting (#614)
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`.
2024-04-22 07:40:44 -04:00

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)
}