mirror of
https://github.com/SamyRai/tercul-backend.git
synced 2025-12-27 00:31:35 +00:00
* feat: add security middleware, graphql apq, and improved linting - Add RateLimit, RequestValidation, and CORS middleware. - Configure middleware chain in API server. - Implement Redis cache for GraphQL Automatic Persisted Queries. - Add .golangci.yml and fix linting issues (shadowing, timeouts). * feat: security, caching and linting config - Fix .golangci.yml config for govet shadow check - (Previous changes: Security middleware, GraphQL APQ, Linting fixes) * fix: resolve remaining lint errors - Fix unhandled errors in tests (errcheck) - Define constants for repeated strings (goconst) - Suppress high complexity warnings with nolint:gocyclo - Fix integer overflow warnings (gosec) - Add package comments - Split long lines (lll) - Rename Analyse -> Analyze (misspell) - Fix naked returns and unused params --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
33 lines
1000 B
Go
33 lines
1000 B
Go
package linguistics
|
|
|
|
import "testing"
|
|
|
|
func TestPoeticAnalyzer_QuatrainABAB(t *testing.T) {
|
|
poem := `In silver light we wander far, light
|
|
A gentle breeze across the sea, breeze
|
|
At quiet dusk we find a star, night
|
|
And in the dark we feel the freeze.`
|
|
// Last words: light, breeze, night, freeze -> ABAB by last 2 letters (ht, ze, ht, ze)
|
|
p := NewPoeticAnalyzer()
|
|
m, err := p.Analyze(Text{Body: poem})
|
|
if err != nil {
|
|
t.Fatalf("Analyze returned error: %v", err)
|
|
}
|
|
if m.RhymeScheme != SchemeABAB {
|
|
t.Errorf("expected rhyme scheme ABAB, got %q", m.RhymeScheme)
|
|
}
|
|
if m.StanzaCount != 1 {
|
|
t.Errorf("expected 1 stanza, got %d", m.StanzaCount)
|
|
}
|
|
if m.LineCount != 4 {
|
|
t.Errorf("expected 4 lines, got %d", m.LineCount)
|
|
}
|
|
if m.Structure != "Quatrain" {
|
|
t.Errorf("expected structure Quatrain, got %q", m.Structure)
|
|
}
|
|
// Meter is heuristic; just ensure it's determined (not Unknown)
|
|
if m.MeterType == "Unknown" {
|
|
t.Errorf("expected a determined meter type, got %q", m.MeterType)
|
|
}
|
|
}
|