summaryrefslogtreecommitdiff
path: root/internal/meta/meta_test.go
blob: 32dee1223a9ef5327123dc6b1e7be8342cac2086 (plain)
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
package meta

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestVersion(t *testing.T) {
	for give, want := range map[string]string{
		// without changes
		"vvv":     "vvv",
		"victory": "victory",
		"voodoo":  "voodoo",
		"foo":     "foo",
		"0.0.0":   "0.0.0",
		"v":       "v",
		"V":       "V",

		// "v" prefix removal
		"v0.0.0": "0.0.0",
		"V0.0.0": "0.0.0",
		"v1":     "1",
		"V1":     "1",

		// with spaces
		" 0.0.0":  "0.0.0",
		"v0.0.0 ": "0.0.0",
		" V0.0.0": "0.0.0",
		"v1 ":     "1",
		" V1":     "1",
		"v ":      "v",
	} {
		version = give

		assert.Equal(t, want, Version())
	}
}

func TestBuildTime(t *testing.T) {
	for give, want := range map[string]string{
		"development":              "development",
		"2021-03-26T13:50:31+0500": "2021-03-26T13:50:31+0500",
	} {
		buildTime = give

		assert.Equal(t, want, BuildTime())
	}
}