all repos — llm_aggregator @ b7690ae41cc0c1076100d43a33ceb2aef502a2c0

A CLI tool to aggregate RSS feeds and summarise them with LLMs

internal/defaults/defaults_test.go (view raw)

 1package defaults
 2
 3import (
 4	"testing"
 5)
 6
 7func TestDefaultValues(t *testing.T) {
 8	tests := []struct {
 9		name     string
10		got      any
11		expected any
12	}{
13		{"DefaultModel", DefaultModel, "deepseek-chat"},
14		{"DefaultBaseURL", DefaultBaseURL, "https://api.deepseek.com"},
15		{"DefaultMaxTokens", DefaultMaxTokens, 4000},
16		{"DefaultTemperature", DefaultTemperature, 0.7},
17		{"DefaultMaxArticlesPerFeed", DefaultMaxArticlesPerFeed, 10},
18		{"DefaultMaxDaysOld", DefaultMaxDaysOld, 7},
19		{"DefaultMaxTotalArticles", DefaultMaxTotalArticles, 20},
20		{"DefaultOutput", DefaultOutput, "text"},
21		{"DefaultIncludeArticles", DefaultIncludeArticles, false},
22	}
23
24	for _, tt := range tests {
25		t.Run(tt.name, func(t *testing.T) {
26			if tt.got != tt.expected {
27				t.Errorf("%s = %v, want %v", tt.name, tt.got, tt.expected)
28			}
29		})
30	}
31}
32
33func TestDefaultSystemPrompt(t *testing.T) {
34	expected := `You are an expert analyst and summariser.
35You analyse content from multiple sources and provide
36concise, insightful summaries based on user requests.
37Focus on key points, trends, and important information.`
38
39	if DefaultSystemPrompt != expected {
40		t.Errorf("DefaultSystemPrompt doesn't match expected value")
41	}
42}
43
44func TestDefaultValuesAreSensible(t *testing.T) {
45	// Verify temperature is in valid range
46	if DefaultTemperature < 0 || DefaultTemperature > 1 {
47		t.Errorf("DefaultTemperature = %f, should be between 0 and 1", DefaultTemperature)
48	}
49
50	// Verify max tokens is reasonable
51	if DefaultMaxTokens < 100 || DefaultMaxTokens > 100000 {
52		t.Errorf("DefaultMaxTokens = %d, should be between 100 and 100000", DefaultMaxTokens)
53	}
54
55	// Verify article limits are reasonable
56	if DefaultMaxArticlesPerFeed < 1 {
57		t.Errorf("DefaultMaxArticlesPerFeed = %d, should be at least 1", DefaultMaxArticlesPerFeed)
58	}
59	if DefaultMaxTotalArticles < 1 {
60		t.Errorf("DefaultMaxTotalArticles = %d, should be at least 1", DefaultMaxTotalArticles)
61	}
62
63	// Verify days old is non-negative
64	if DefaultMaxDaysOld < 0 {
65		t.Errorf("DefaultMaxDaysOld = %d, should be non-negative", DefaultMaxDaysOld)
66	}
67}
68
69func TestDefaultBaseURLIsValid(t *testing.T) {
70	// Base URL should be a valid URL starting with http
71	if len(DefaultBaseURL) < 4 {
72		t.Errorf("DefaultBaseURL = %q, too short", DefaultBaseURL)
73	}
74	if DefaultBaseURL[:4] != "http" {
75		t.Errorf("DefaultBaseURL = %q, should start with http", DefaultBaseURL)
76	}
77}
78
79func TestOutputFormatChoices(t *testing.T) {
80	validOutputs := map[string]bool{
81		"text":     true,
82		"json":     true,
83		"markdown": true,
84	}
85
86	if !validOutputs[DefaultOutput] {
87		t.Errorf("DefaultOutput = %q, should be one of text, json, markdown", DefaultOutput)
88	}
89}