-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_suite.go
More file actions
93 lines (83 loc) · 2.22 KB
/
test_suite.go
File metadata and controls
93 lines (83 loc) · 2.22 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//go:build test
// +build test
package main
import (
"fmt"
"os"
"os/exec"
"strings"
)
// TestSuite represents a test suite configuration
type TestSuite struct {
Name string
Path string
Description string
}
func main() {
testSuites := []TestSuite{
{
Name: "Models",
Path: "./cmd/glad/internal/models",
Description: "User model validation, password hashing, and data operations",
},
{
Name: "Auth",
Path: "./pkg/auth",
Description: "JWT token generation, validation, and expiration",
},
{
Name: "Middleware",
Path: "./pkg/middleware",
Description: "JWT authentication middleware and request validation",
},
{
Name: "Database",
Path: "./cmd/glad/internal/database",
Description: "Mock repository operations and concurrent access",
},
{
Name: "API Handlers",
Path: "./cmd/glad/internal/api",
Description: "REST API endpoints, registration, login, and user operations",
},
{
Name: "Main Lambda",
Path: "./cmd/glad",
Description: "Lambda handler routing and request processing",
},
}
fmt.Println("🧪 Go-on-AWS Test Suite Runner")
fmt.Println("===============================\n")
overallSuccess := true
for i, suite := range testSuites {
fmt.Printf("[%d/%d] Running %s Tests\n", i+1, len(testSuites), suite.Name)
fmt.Printf("📝 %s\n", suite.Description)
fmt.Printf("📁 %s\n\n", suite.Path)
cmd := exec.Command("go", "test", "-v", suite.Path)
cmd.Env = os.Environ()
output, err := cmd.CombinedOutput()
if err != nil {
fmt.Printf("❌ %s Tests FAILED\n", suite.Name)
overallSuccess = false
} else {
fmt.Printf("✅ %s Tests PASSED\n", suite.Name)
}
// Show test results summary
outputStr := string(output)
lines := strings.Split(outputStr, "\n")
for _, line := range lines {
if strings.Contains(line, "PASS") || strings.Contains(line, "FAIL") || strings.Contains(line, "RUN") {
fmt.Printf(" %s\n", line)
}
}
fmt.Println()
}
fmt.Println("===============================")
if overallSuccess {
fmt.Println("🎉 All test suites PASSED!")
os.Exit(0)
} else {
fmt.Println("💥 Some test suites FAILED!")
os.Exit(1)
}
}