✨ feat: implement API v2 with feature flag control
- Added /api/v2/greet POST endpoint with JSON request/response - Implemented ServiceV2 with Hello my friend <name>! greeting format - Added api.v2_enabled feature flag (default: false) - Extended BDD tests to cover v2 scenarios - Maintained full backward compatibility with v1 API - Added DLC_API_V2_ENABLED environment variable support - Created ADR 0010-api-v2-feature-flag.md - Updated configuration system to support API versioning
This commit is contained in:
28
pkg/greet/greet_v2_test.go
Normal file
28
pkg/greet/greet_v2_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package greet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestServiceV2_GreetV2(t *testing.T) {
|
||||
service := NewServiceV2()
|
||||
tests := []struct {
|
||||
name string
|
||||
expected string
|
||||
}{
|
||||
{"", "Hello my friend!"},
|
||||
{"John", "Hello my friend John!"},
|
||||
{"Alice", "Hello my friend Alice!"},
|
||||
{" ", "Hello my friend !"}, // spaces are not considered empty
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
result := service.GreetV2(context.Background(), tt.name)
|
||||
if result != tt.expected {
|
||||
t.Errorf("GreetV2(%q) = %q, want %q", tt.name, result, tt.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user