
- Add comprehensive Git workflow automation tools - Include branch management utilities - Add commit helpers with conventional commit support - Implement GitHub integration for PR management - Add configuration management system - Include comprehensive test coverage - Add professional documentation and examples
53 lines
1.2 KiB
Go
53 lines
1.2 KiB
Go
package version
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestGetVersion(t *testing.T) {
|
|
// Save original values
|
|
originalVersion := Version
|
|
originalGitCommit := GitCommit
|
|
originalBuildDate := BuildDate
|
|
|
|
// Reset values
|
|
Version = "0.1.0"
|
|
GitCommit = ""
|
|
BuildDate = ""
|
|
|
|
// Test with just version
|
|
result := GetVersion()
|
|
expected := "0.1.0"
|
|
if result != expected {
|
|
t.Errorf("Expected '%s', got '%s'", expected, result)
|
|
}
|
|
|
|
// Test with version and git commit
|
|
GitCommit = "abc123"
|
|
result = GetVersion()
|
|
expected = "0.1.0 (abc123)"
|
|
if result != expected {
|
|
t.Errorf("Expected '%s', got '%s'", expected, result)
|
|
}
|
|
|
|
// Test with version, git commit, and build date
|
|
BuildDate = "2023-01-01"
|
|
result = GetVersion()
|
|
expected = "0.1.0 (abc123) built on 2023-01-01"
|
|
if result != expected {
|
|
t.Errorf("Expected '%s', got '%s'", expected, result)
|
|
}
|
|
|
|
// Test with version and build date (no git commit)
|
|
GitCommit = ""
|
|
result = GetVersion()
|
|
expected = "0.1.0 built on 2023-01-01"
|
|
if result != expected {
|
|
t.Errorf("Expected '%s', got '%s'", expected, result)
|
|
}
|
|
|
|
// Restore original values
|
|
Version = originalVersion
|
|
GitCommit = originalGitCommit
|
|
BuildDate = originalBuildDate
|
|
} |