diff options
| author | Adam Mathes <adam@adammathes.com> | 2026-02-18 07:52:29 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-18 07:52:29 -0800 |
| commit | f66114a6159e3830f5c6ea772f76c988ae65623a (patch) | |
| tree | 5bff187b7e89b6e36c4c4948deab4b377e030b0b /cmd | |
| parent | 804e55984ba88a768c6518904ce45f30ea27da9f (diff) | |
| parent | 269e44da41f9feed32214bbab6fc16ec88fffd85 (diff) | |
| download | neko-f66114a6159e3830f5c6ea772f76c988ae65623a.tar.gz neko-f66114a6159e3830f5c6ea772f76c988ae65623a.tar.bz2 neko-f66114a6159e3830f5c6ea772f76c988ae65623a.zip | |
Merge pull request #18 from adammathes/claude/improve-test-coverage-iBkwc
Add comprehensive test coverage for security and import features
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/neko/main_test.go | 54 |
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) +} |
