Rank candidate articles using the selected preference and enforce global and per-source article limits. Refs #6 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
30 lines
1.0 KiB
Go
30 lines
1.0 KiB
Go
package migrations
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestArticleLimitsMigrationPreservesGlobalSettingAndDefaultsSourceLimit(t *testing.T) {
|
|
up, err := os.ReadFile("000012_article_limits.up.sql")
|
|
if err != nil {
|
|
t.Fatalf("read migration 000012: %v", err)
|
|
}
|
|
down, err := os.ReadFile("000012_article_limits.down.sql")
|
|
if err != nil {
|
|
t.Fatalf("read migration rollback 000012: %v", err)
|
|
}
|
|
upSQL := strings.ToLower(string(up))
|
|
if !strings.Contains(upSQL, "article_limit") || !strings.Contains(upSQL, "default 20") {
|
|
t.Errorf("migration must add source.article_limit with default 20; got %s", upSQL)
|
|
}
|
|
if strings.Contains(upSQL, "delete from settings") || strings.Contains(upSQL, "summary_max_articles')") {
|
|
t.Errorf("migration must preserve historical summary_max_articles setting; got %s", upSQL)
|
|
}
|
|
downSQL := strings.ToLower(string(down))
|
|
if !strings.Contains(downSQL, "drop column article_limit") {
|
|
t.Errorf("rollback must remove only the source article_limit column; got %s", downSQL)
|
|
}
|
|
}
|