mirror of
https://github.com/mgechev/revive.git
synced 2025-11-29 22:28:23 +02:00
refactor: extract getVersion function (#1127)
Co-authored-by: chavacava <salvador.cavadini@gmail.com>
This commit is contained in:
@@ -86,3 +86,44 @@ func TestXDGConfigDirNoFile(t *testing.T) {
|
||||
t.Errorf("got %q, wanted %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetVersion(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
version string
|
||||
commit string
|
||||
date string
|
||||
builtBy string
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "Development version",
|
||||
version: defaultVersion,
|
||||
commit: defaultCommit,
|
||||
date: defaultDate,
|
||||
builtBy: defaultBuilder,
|
||||
want: "version \n",
|
||||
},
|
||||
{
|
||||
name: "Release version",
|
||||
version: "v1.5.0-12-g7ee4500-dev",
|
||||
commit: "7ee4500e125e2d1b12653b2c8e140fec380919b4",
|
||||
date: "2024-11-15 10:52 UTC",
|
||||
builtBy: "builder",
|
||||
want: `Version: v1.5.0-12-g7ee4500-dev
|
||||
Commit: 7ee4500e125e2d1b12653b2c8e140fec380919b4
|
||||
Built 2024-11-15 10:52 UTC by builder
|
||||
`,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := getVersion(tt.builtBy, tt.date, tt.commit, tt.version)
|
||||
|
||||
if got != tt.want {
|
||||
t.Errorf("getVersion() = %q, want %q", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user