aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorClaude <noreply@anthropic.com>2026-02-18 06:18:28 +0000
committerClaude <noreply@anthropic.com>2026-02-18 06:18:28 +0000
commit269e44da41f9feed32214bbab6fc16ec88fffd85 (patch)
tree6c6312b8ad3fd9175b2992e3e044fa6257e3ef43 /cmd
parent8eb86cdc49c3c2f69d8a64f855220ebd68be336c (diff)
downloadneko-269e44da41f9feed32214bbab6fc16ec88fffd85.tar.gz
neko-269e44da41f9feed32214bbab6fc16ec88fffd85.tar.bz2
neko-269e44da41f9feed32214bbab6fc16ec88fffd85.zip
Increase test coverage across lowest-coverage packagesclaude/improve-test-coverage-iBkwc
Major coverage improvements: - safehttp: 46.7% -> 93.3% (SafeDialer, redirect checking, SSRF protection) - api: 81.8% -> 96.4% (HandleImport 0% -> 100%, stream errors, content types) - importer: 85.3% -> 94.7% (ImportFeeds dispatcher, OPML nesting, edge cases) - cmd/neko: 77.1% -> 85.4% (purge, secure-cookies, minutes, allow-local flags) New tests added: - Security regression tests (CSRF token uniqueness, mismatch rejection, auth cookie HttpOnly, security headers, API auth requirements) - Stress tests for concurrent mixed operations and rapid state toggling - SSRF protection tests for SafeDialer hostname resolution and redirect paths https://claude.ai/code/session_01XUBh32rHpbYue1JYXSH64Q
Diffstat (limited to 'cmd')
-rw-r--r--cmd/neko/main_test.go54
1 files changed, 54 insertions, 0 deletions
diff --git a/cmd/neko/main_test.go b/cmd/neko/main_test.go
index b03d6c8..4403e5b 100644
--- a/cmd/neko/main_test.go
+++ b/cmd/neko/main_test.go
@@ -122,3 +122,57 @@ func TestRunNoArgs(t *testing.T) {
t.Errorf("Run with no args failed: %v", err)
}
}
+
+func TestRunPurge(t *testing.T) {
+ dbPath := filepath.Join(t.TempDir(), "test_purge.db")
+ err := Run([]string{"-d", dbPath, "-purge", "30"})
+ if err != nil {
+ t.Errorf("Run -purge should succeed, got %v", err)
+ }
+}
+
+func TestRunPurgeUnread(t *testing.T) {
+ dbPath := filepath.Join(t.TempDir(), "test_purge_unread.db")
+ err := Run([]string{"-d", dbPath, "-purge", "30", "-purge-unread"})
+ if err != nil {
+ t.Errorf("Run -purge -purge-unread should succeed, got %v", err)
+ }
+}
+
+func TestRunSecureCookies(t *testing.T) {
+ dbPath := filepath.Join(t.TempDir(), "test_secure.db")
+ config.Config.Port = -1
+ err := Run([]string{"-d", dbPath, "-secure-cookies"})
+ if err != nil {
+ t.Errorf("Run -secure-cookies should succeed, got %v", err)
+ }
+ if !config.Config.SecureCookies {
+ t.Error("Expected SecureCookies to be true")
+ }
+}
+
+func TestRunMinutesFlag(t *testing.T) {
+ dbPath := filepath.Join(t.TempDir(), "test_minutes.db")
+ config.Config.Port = -1
+ err := Run([]string{"-d", dbPath, "-m", "30"})
+ if err != nil {
+ t.Errorf("Run -m 30 should succeed, got %v", err)
+ }
+ if config.Config.CrawlMinutes != 30 {
+ t.Errorf("Expected CrawlMinutes=30, got %d", config.Config.CrawlMinutes)
+ }
+}
+
+func TestRunAllowLocal(t *testing.T) {
+ dbPath := filepath.Join(t.TempDir(), "test_local.db")
+ config.Config.Port = -1
+ err := Run([]string{"-d", dbPath, "-allow-local"})
+ if err != nil {
+ t.Errorf("Run -allow-local should succeed, got %v", err)
+ }
+}
+
+func TestBackgroundCrawlNegative(_ *testing.T) {
+ // Negative minutes should return immediately
+ backgroundCrawl(-1)
+}