Skip to content

Commit a4b5810

Browse files
authored
Merge pull request #300 from devfeel/develop
v1.8.1 - Quality Improvement Release
2 parents 34d5708 + 73d2721 commit a4b5810

25 files changed

Lines changed: 2722 additions & 394 deletions

File tree

.github/workflows/test.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [ aicode, master, develop ]
6+
pull_request:
7+
branches: [ aicode, master ]
8+
9+
jobs:
10+
test:
11+
name: Test with Go ${{ matrix.go-version }}
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
go-version: ['1.21', '1.22', '1.23']
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version: ${{ matrix.go-version }}
25+
26+
- name: Cache Go modules
27+
uses: actions/cache@v4
28+
with:
29+
path: ~/go/pkg/mod
30+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
31+
restore-keys: |
32+
${{ runner.os }}-go-
33+
34+
- name: Download dependencies
35+
run: go mod download
36+
37+
- name: Run go vet
38+
run: go vet ./...
39+
40+
- name: Run tests
41+
run: go test ./... -v -coverprofile=coverage.out
42+
43+
- name: Upload coverage
44+
uses: codecov/codecov-action@v4
45+
if: matrix.go-version == '1.22'
46+
with:
47+
files: ./coverage.out
48+
flags: unittests
49+
fail_ci_if_error: false
50+
51+
- name: Generate coverage report
52+
if: matrix.go-version == '1.22'
53+
run: |
54+
go tool cover -func=coverage.out
55+
echo "## Test Coverage Report" >> $GITHUB_STEP_SUMMARY
56+
echo "" >> $GITHUB_STEP_SUMMARY
57+
go tool cover -func=coverage.out >> $GITHUB_STEP_SUMMARY

.gitignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
8+
# Test binary, built with `go test -c`
9+
*.test
10+
11+
# Output of the go coverage tool
12+
*.out
13+
coverage.out
14+
coverage.html
15+
16+
# Dependency directories
17+
vendor/
18+
19+
# Go workspace file
20+
go.work
21+
22+
# IDE
23+
.idea/
24+
.vscode/
25+
*.swp
26+
*.swo
27+
28+
# OS
29+
.DS_Store
30+
Thumbs.db
31+
32+
# Project specific
33+
example/group/group_test

TESTING.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Test Coverage Improvement Plan
2+
3+
## Current Status (2026-03-04)
4+
5+
### Test Coverage Summary
6+
- **Overall**: 19.0%
7+
- **Core Modules**: ~25% (needs improvement)
8+
- **Router**: ~11% (critical)
9+
- **Tree**: ~10% (critical)
10+
- **Upload**: 0% (no tests)
11+
- **Session**: 23.5%
12+
- **JSON**: 77.8% ✅
13+
- **String**: 78.6% ✅
14+
15+
## Goals
16+
17+
### Phase 1: Core Testing (Target: 35%+)
18+
- [ ] Add router_test.go tests
19+
- [ ] Add tree_test.go tests
20+
- [ ] Add uploadfile_test.go tests
21+
- [ ] Improve group_test.go coverage
22+
23+
### Phase 2: Edge Cases (Target: 45%+)
24+
- [ ] Route conflict tests
25+
- [ ] Parameter parsing edge cases
26+
- [ ] Session concurrent tests
27+
- [ ] Middleware chain tests
28+
29+
### Phase 3: Benchmarks
30+
- [ ] Router matching benchmarks
31+
- [ ] Session read/write benchmarks
32+
- [ ] Middleware chain benchmarks
33+
34+
## Running Tests
35+
36+
```bash
37+
# Run all tests with coverage
38+
go test ./... -coverprofile=coverage.out
39+
40+
# View coverage report
41+
go tool cover -func=coverage.out
42+
43+
# Generate HTML coverage report
44+
go tool cover -html=coverage.out -o coverage.html
45+
```
46+
47+
## Test Naming Convention
48+
49+
```
50+
Test<FunctionName>_<Scenario>_<ExpectedResult>
51+
52+
Examples:
53+
- TestRouter_AddRoute_ValidPath_Success
54+
- TestRouter_AddRoute_EmptyPath_Error
55+
- TestGroup_Use_MiddlewareChain_Order
56+
```
57+
58+
## CI Integration
59+
60+
GitHub Actions workflow in `.github/workflows/test.yml` runs on:
61+
- Push to aicode, master branches
62+
- Pull requests

0 commit comments

Comments
 (0)