resource_test.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Copyright 2025 BackendServerTemplate Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package resource
  5. import "testing"
  6. func TestVersion(t *testing.T) {
  7. t.Run("Version-Variable", func(t *testing.T) {
  8. if Version == "" {
  9. t.Fatalf("Version is empty")
  10. } else if SemanticVersioning == "" {
  11. t.Fatalf("SemanticVersioning is empty")
  12. } else if "v"+SemanticVersioning != Version {
  13. t.Fatalf("SemanticVersioning and Version do not match")
  14. } else if !utilsIsSemanticVersion(SemanticVersioning) {
  15. t.Fatalf("Non-semantic version")
  16. }
  17. })
  18. t.Run("Default-Version", func(t *testing.T) {
  19. defer func() {
  20. if err := recover(); err != nil {
  21. t.Fatalf("Get default version panic: %v", err)
  22. }
  23. }()
  24. _ = getDefaultVersion()
  25. })
  26. t.Run("Git-Version", func(t *testing.T) {
  27. defer func() {
  28. if err := recover(); err != nil {
  29. t.Fatalf("Get git version panic: %v", err)
  30. }
  31. }()
  32. _ = getGitTagVersion()
  33. })
  34. t.Run("Random-Version", func(t *testing.T) {
  35. defer func() {
  36. if err := recover(); err != nil {
  37. t.Fatalf("Get random version panic: %v", err)
  38. }
  39. }()
  40. ver := getRandomVersion()
  41. if ver == "" {
  42. t.Fatalf("Random Version is empty")
  43. }
  44. })
  45. }
  46. func TestLicense(t *testing.T) {
  47. if License == "" {
  48. t.Fatalf("License is empty")
  49. }
  50. }
  51. func TestReport(t *testing.T) {
  52. if Report == "" {
  53. t.Fatalf("Report is empty")
  54. }
  55. }
  56. func TestName(t *testing.T) {
  57. if Name == "" {
  58. t.Fatalf("Name is empty")
  59. }
  60. }
  61. func TestBuildDate(t *testing.T) {
  62. if buildDateTxt == "" {
  63. t.Fatalf("Build Date is empty")
  64. }
  65. }
  66. func TestRandomData(t *testing.T) {
  67. if randomData == "" {
  68. t.Fatalf("Randome Data is empty")
  69. }
  70. }