feat: implement YAML-based configuration, .env support, and customizable prompt templates for AI analysis

This commit is contained in:
2026-08-22 10:17:38 -07:00
parent 7ec91f384f
commit 0de312edbd
30 changed files with 895 additions and 211 deletions
+59
View File
@@ -0,0 +1,59 @@
package db
import (
"os"
"path/filepath"
"testing"
)
func TestLoadTargetsFromYAMLRespectsIsActive(t *testing.T) {
tempDir := t.TempDir()
dbPath := filepath.Join(tempDir, "test_targets_active.db")
yamlPath := filepath.Join(tempDir, "targets.yaml")
yamlContent := `targets:
- name: "Google Seattle"
target_url: "https://google.com/jobs"
platform: "google_jobs"
is_active: false
- name: "Apple Seattle"
target_url: "https://apple.com/jobs"
platform: "apple"
is_active: true
`
if err := os.WriteFile(yamlPath, []byte(yamlContent), 0644); err != nil {
t.Fatalf("failed to write yaml: %v", err)
}
database, err := InitDB(dbPath)
if err != nil {
t.Fatalf("failed to init db: %v", err)
}
defer func() { _ = database.Close() }()
if err := database.LoadTargetsFromYAML(yamlPath); err != nil {
t.Fatalf("LoadTargetsFromYAML failed: %v", err)
}
targets, err := database.GetAllTargets()
if err != nil {
t.Fatalf("GetAllTargets failed: %v", err)
}
if len(targets) != 2 {
t.Fatalf("expected 2 targets, got %d", len(targets))
}
for _, target := range targets {
if target.TargetURL == "https://google.com/jobs" {
if target.IsActive != false {
t.Errorf("expected Google target to have is_active=false, got %v", target.IsActive)
}
}
if target.TargetURL == "https://apple.com/jobs" {
if target.IsActive != true {
t.Errorf("expected Apple target to have is_active=true, got %v", target.IsActive)
}
}
}
}