forked from kuskoman/logstash-exporter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
version_test.go
52 lines (41 loc) · 1.31 KB
/
version_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package config
import (
"runtime"
"testing"
)
func TestGetBuildInfo(t *testing.T) {
versionInfo := GetVersionInfo()
if versionInfo.Version == "" {
t.Error("Expected Version to be set")
}
if versionInfo.GitCommit == "" {
t.Error("Expected GitCommit to be set")
}
if versionInfo.GoVersion != runtime.Version() {
t.Errorf("Expected GoVersion: %s, but got: %s", runtime.Version(), versionInfo.GoVersion)
}
if versionInfo.BuildArch != runtime.GOARCH {
t.Errorf("Expected BuildArch: %s, but got: %s", runtime.GOARCH, versionInfo.BuildArch)
}
if versionInfo.BuildOS != runtime.GOOS {
t.Errorf("Expected BuildOS: %s, but got: %s", runtime.GOOS, versionInfo.BuildOS)
}
if versionInfo.BuildDate == "" {
t.Error("Expected BuildDate to be set")
}
}
func TestVersionInfoString(t *testing.T) {
versionInfo := &VersionInfo{
Version: "test-version",
GitCommit: "test-commit",
GoVersion: "test-go-version",
BuildArch: "test-arch",
BuildOS: "test-os",
BuildDate: "test-date",
}
expectedString := "Version: test-version, GitCommit: test-commit, GoVersion: test-go-version, BuildArch: test-arch, BuildOS: test-os, BuildDate: test-date"
versionInfoString := versionInfo.String()
if versionInfoString != expectedString {
t.Errorf("Expected string: %s, but got: %s", expectedString, versionInfoString)
}
}