Compare commits
2 Commits
5fdbb729bd
...
7ffacb6620
| Author | SHA1 | Date | |
|---|---|---|---|
| 7ffacb6620 | |||
| 3f3545ba15 |
@@ -150,8 +150,10 @@ When working on this project, follow this workflow:
|
|||||||
- Use descriptive branch names (e.g., `feature/epic1-http-server`, `bugfix/auth-token-expiry`, `enhancement/rate-limiting`)
|
- Use descriptive branch names (e.g., `feature/epic1-http-server`, `bugfix/auth-token-expiry`, `enhancement/rate-limiting`)
|
||||||
- Branch names should follow the pattern: `{type}/{epic}-{short-description}` or `{type}/{story-id}-{short-description}`
|
- Branch names should follow the pattern: `{type}/{epic}-{short-description}` or `{type}/{story-id}-{short-description}`
|
||||||
- **ALWAYS create a commit** after successfully implementing a feature that:
|
- **ALWAYS create a commit** after successfully implementing a feature that:
|
||||||
- ✅ Builds successfully (`go build` passes)
|
- ✅ Builds successfully (`make build` passes)
|
||||||
- ✅ Tests pass (`go test` passes)
|
- ✅ Tests pass (`make test` passes)
|
||||||
|
- ✅ Lint pass (`make lint` passes)
|
||||||
|
- ✅ fmt-check pass (`make fmt-check` passes)
|
||||||
- ✅ Meets all acceptance criteria from the story
|
- ✅ Meets all acceptance criteria from the story
|
||||||
- Commit messages should be clear and descriptive, referencing the story/epic when applicable
|
- Commit messages should be clear and descriptive, referencing the story/epic when applicable
|
||||||
- Never commit directly to `main` branch
|
- Never commit directly to `main` branch
|
||||||
|
|||||||
4
Makefile
4
Makefile
@@ -49,11 +49,11 @@ help:
|
|||||||
# Development commands
|
# Development commands
|
||||||
test:
|
test:
|
||||||
@echo "Running tests..."
|
@echo "Running tests..."
|
||||||
CGO_ENABLED=1 $(GO) test -v ./...
|
CGO_ENABLED=1 $(GO) test -v -race ./...
|
||||||
|
|
||||||
test-coverage:
|
test-coverage:
|
||||||
@echo "Running tests with coverage..."
|
@echo "Running tests with coverage..."
|
||||||
CGO_ENABLED=1 $(GO) test -v -coverprofile=coverage.out ./...
|
CGO_ENABLED=1 $(GO) test -v -race -coverprofile=coverage.out ./...
|
||||||
$(GO) tool cover -html=coverage.out -o coverage.html
|
$(GO) tool cover -html=coverage.out -o coverage.html
|
||||||
@echo "Coverage report generated: coverage.html"
|
@echo "Coverage report generated: coverage.html"
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package errorbus
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -61,7 +62,10 @@ func TestChannelBus_Publish(t *testing.T) {
|
|||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
|
||||||
// Verify error was logged
|
// Verify error was logged
|
||||||
if len(mockLogger.errors) == 0 {
|
mockLogger.mu.Lock()
|
||||||
|
errorCount := len(mockLogger.errors)
|
||||||
|
mockLogger.mu.Unlock()
|
||||||
|
if errorCount == 0 {
|
||||||
t.Error("Expected error to be logged")
|
t.Error("Expected error to be logged")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +88,10 @@ func TestChannelBus_Publish_NilError(t *testing.T) {
|
|||||||
time.Sleep(50 * time.Millisecond)
|
time.Sleep(50 * time.Millisecond)
|
||||||
|
|
||||||
// Verify nil error was not logged
|
// Verify nil error was not logged
|
||||||
if len(mockLogger.errors) > 0 {
|
mockLogger.mu.Lock()
|
||||||
|
errorCount := len(mockLogger.errors)
|
||||||
|
mockLogger.mu.Unlock()
|
||||||
|
if errorCount > 0 {
|
||||||
t.Error("Expected nil error to be ignored")
|
t.Error("Expected nil error to be ignored")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +114,10 @@ func TestChannelBus_Publish_WithContext(t *testing.T) {
|
|||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
|
||||||
// Verify error was logged with context
|
// Verify error was logged with context
|
||||||
if len(mockLogger.errors) == 0 {
|
mockLogger.mu.Lock()
|
||||||
|
errorCount := len(mockLogger.errors)
|
||||||
|
mockLogger.mu.Unlock()
|
||||||
|
if errorCount == 0 {
|
||||||
t.Error("Expected error to be logged")
|
t.Error("Expected error to be logged")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,12 +191,15 @@ func TestChannelBus_ChannelFull(t *testing.T) {
|
|||||||
// mockLogger implements logger.Logger for testing.
|
// mockLogger implements logger.Logger for testing.
|
||||||
type mockLogger struct {
|
type mockLogger struct {
|
||||||
errors []string
|
errors []string
|
||||||
|
mu sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockLogger) Debug(msg string, fields ...logger.Field) {}
|
func (m *mockLogger) Debug(msg string, fields ...logger.Field) {}
|
||||||
func (m *mockLogger) Info(msg string, fields ...logger.Field) {}
|
func (m *mockLogger) Info(msg string, fields ...logger.Field) {}
|
||||||
func (m *mockLogger) Warn(msg string, fields ...logger.Field) {}
|
func (m *mockLogger) Warn(msg string, fields ...logger.Field) {}
|
||||||
func (m *mockLogger) Error(msg string, fields ...logger.Field) {
|
func (m *mockLogger) Error(msg string, fields ...logger.Field) {
|
||||||
|
m.mu.Lock()
|
||||||
|
defer m.mu.Unlock()
|
||||||
m.errors = append(m.errors, msg)
|
m.errors = append(m.errors, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestRequestIDMiddleware(t *testing.T) {
|
func TestRequestIDMiddleware(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
gin.SetMode(gin.TestMode)
|
gin.SetMode(gin.TestMode)
|
||||||
|
|
||||||
router := gin.New()
|
router := gin.New()
|
||||||
@@ -47,8 +45,6 @@ func TestRequestIDMiddleware(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRequestIDMiddleware_ExistingHeader(t *testing.T) {
|
func TestRequestIDMiddleware_ExistingHeader(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
gin.SetMode(gin.TestMode)
|
gin.SetMode(gin.TestMode)
|
||||||
|
|
||||||
router := gin.New()
|
router := gin.New()
|
||||||
@@ -70,8 +66,6 @@ func TestRequestIDMiddleware_ExistingHeader(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestLoggingMiddleware(t *testing.T) {
|
func TestLoggingMiddleware(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
gin.SetMode(gin.TestMode)
|
gin.SetMode(gin.TestMode)
|
||||||
|
|
||||||
mockLogger := &mockLogger{}
|
mockLogger := &mockLogger{}
|
||||||
@@ -99,8 +93,6 @@ func TestLoggingMiddleware(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPanicRecoveryMiddleware(t *testing.T) {
|
func TestPanicRecoveryMiddleware(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
gin.SetMode(gin.TestMode)
|
gin.SetMode(gin.TestMode)
|
||||||
|
|
||||||
mockErrorBus := &mockErrorBusMiddleware{}
|
mockErrorBus := &mockErrorBusMiddleware{}
|
||||||
@@ -128,8 +120,6 @@ func TestPanicRecoveryMiddleware(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPanicRecoveryMiddleware_ErrorPanic(t *testing.T) {
|
func TestPanicRecoveryMiddleware_ErrorPanic(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
gin.SetMode(gin.TestMode)
|
gin.SetMode(gin.TestMode)
|
||||||
|
|
||||||
mockErrorBus := &mockErrorBusMiddleware{}
|
mockErrorBus := &mockErrorBusMiddleware{}
|
||||||
@@ -156,8 +146,6 @@ func TestPanicRecoveryMiddleware_ErrorPanic(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCORSMiddleware(t *testing.T) {
|
func TestCORSMiddleware(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
gin.SetMode(gin.TestMode)
|
gin.SetMode(gin.TestMode)
|
||||||
|
|
||||||
router := gin.New()
|
router := gin.New()
|
||||||
@@ -183,8 +171,6 @@ func TestCORSMiddleware(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCORSMiddleware_OPTIONS(t *testing.T) {
|
func TestCORSMiddleware_OPTIONS(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
gin.SetMode(gin.TestMode)
|
gin.SetMode(gin.TestMode)
|
||||||
|
|
||||||
router := gin.New()
|
router := gin.New()
|
||||||
@@ -205,8 +191,6 @@ func TestCORSMiddleware_OPTIONS(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTimeoutMiddleware(t *testing.T) {
|
func TestTimeoutMiddleware(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
gin.SetMode(gin.TestMode)
|
gin.SetMode(gin.TestMode)
|
||||||
|
|
||||||
router := gin.New()
|
router := gin.New()
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestNewServer(t *testing.T) {
|
func TestNewServer(t *testing.T) {
|
||||||
t.Parallel()
|
gin.SetMode(gin.TestMode)
|
||||||
|
|
||||||
mockConfig := &mockConfigProvider{
|
mockConfig := &mockConfigProvider{
|
||||||
values: map[string]any{
|
values: map[string]any{
|
||||||
@@ -51,7 +51,7 @@ func TestNewServer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestNewServer_DefaultValues(t *testing.T) {
|
func TestNewServer_DefaultValues(t *testing.T) {
|
||||||
t.Parallel()
|
gin.SetMode(gin.TestMode)
|
||||||
|
|
||||||
mockConfig := &mockConfigProvider{
|
mockConfig := &mockConfigProvider{
|
||||||
values: map[string]any{
|
values: map[string]any{
|
||||||
@@ -76,7 +76,7 @@ func TestNewServer_DefaultValues(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestServer_Router(t *testing.T) {
|
func TestServer_Router(t *testing.T) {
|
||||||
t.Parallel()
|
gin.SetMode(gin.TestMode)
|
||||||
|
|
||||||
mockConfig := &mockConfigProvider{
|
mockConfig := &mockConfigProvider{
|
||||||
values: map[string]any{
|
values: map[string]any{
|
||||||
@@ -102,7 +102,7 @@ func TestServer_Router(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestServer_Shutdown(t *testing.T) {
|
func TestServer_Shutdown(t *testing.T) {
|
||||||
t.Parallel()
|
gin.SetMode(gin.TestMode)
|
||||||
|
|
||||||
mockConfig := &mockConfigProvider{
|
mockConfig := &mockConfigProvider{
|
||||||
values: map[string]any{
|
values: map[string]any{
|
||||||
@@ -140,8 +140,6 @@ func TestServer_Shutdown(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestServer_HealthEndpoints(t *testing.T) {
|
func TestServer_HealthEndpoints(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
gin.SetMode(gin.TestMode)
|
gin.SetMode(gin.TestMode)
|
||||||
|
|
||||||
mockConfig := &mockConfigProvider{
|
mockConfig := &mockConfigProvider{
|
||||||
@@ -181,8 +179,6 @@ func TestServer_HealthEndpoints(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestServer_MetricsEndpoint(t *testing.T) {
|
func TestServer_MetricsEndpoint(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
gin.SetMode(gin.TestMode)
|
gin.SetMode(gin.TestMode)
|
||||||
|
|
||||||
mockConfig := &mockConfigProvider{
|
mockConfig := &mockConfigProvider{
|
||||||
|
|||||||
Reference in New Issue
Block a user