MCPcopy Index your code
hub / github.com/coder/coder / TestBuildInfo

Function TestBuildInfo

buildinfo/buildinfo_test.go:13–104  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestBuildInfo(t *testing.T) {
14 t.Parallel()
15 t.Run("Version", func(t *testing.T) {
16 t.Parallel()
17 version := buildinfo.Version()
18 require.True(t, semver.IsValid(version))
19 prerelease := semver.Prerelease(version)
20 require.Equal(t, "-devel", prerelease)
21 require.Equal(t, "v0", semver.Major(version))
22 })
23 t.Run("ExternalURL", func(t *testing.T) {
24 t.Parallel()
25 require.Equal(t, "https://github.com/coder/coder", buildinfo.ExternalURL())
26 })
27 // Tests don't include Go build info.
28 t.Run("NoTime", func(t *testing.T) {
29 t.Parallel()
30 _, valid := buildinfo.Time()
31 require.False(t, valid)
32 })
33
34 t.Run("VersionsMatch", func(t *testing.T) {
35 t.Parallel()
36
37 type testcase struct {
38 name string
39 v1 string
40 v2 string
41 expectMatch bool
42 }
43
44 cases := []testcase{
45 {
46 name: "OK",
47 v1: "v1.2.3",
48 v2: "v1.2.3",
49 expectMatch: true,
50 },
51 // Test that we return true if a developer version is detected.
52 // Developers do not need to be warned of mismatched versions.
53 {
54 name: "DevelIgnored",
55 v1: "v0.0.0-devel+123abac",
56 v2: "v1.2.3",
57 expectMatch: true,
58 },
59 // Our CI instance uses a "-devel" prerelease
60 // flag.
61 {
62 name: "DevelPreleaseMajor",
63 v1: "v1.1.1-devel+123abac",
64 v2: "v1.2.3",
65 expectMatch: false,
66 },
67 {
68 name: "DevelPreleaseSame",
69 v1: "v1.1.1-devel+123abac",
70 v2: "v1.1.9",

Callers

nothing calls this directly

Calls 6

VersionFunction · 0.92
ExternalURLFunction · 0.92
TimeFunction · 0.92
VersionsMatchFunction · 0.92
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected