fix: bug fixes, test coverage, and CI workflow
- Fix Nodes.First() panic on empty slice (return nil) - Fix ticker leak in archive.go (create once, defer Stop) - Fix cookie path matching for empty and root paths - Fix lost query params in google.go (u.Query().Set was discarded) - Fix type assertion panic in useragents.go - Fix dropped date parse error in powerball.go - Remove unreachable dead code in megamillions.go and powerball.go - Simplify document.go WaitForNetworkIdle, remove unused root field - Remove debug fmt.Println calls across codebase - Replace panic(err) with stderr+exit in all cmd/ programs - Fix duckduckgo cmd: remove useless defer, return error on bad safesearch - Fix archive cmd: ToConfig returns error instead of panicking - Add 39+ unit tests across 6 new test files - Add Gitea Actions CI workflow (build, test, vet in parallel) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -41,9 +41,20 @@ func deferClose(cl io.Closer) {
|
||||
func getDrawing(_ context.Context, doc extractor.Document) (*Drawing, error) {
|
||||
var drawing Drawing
|
||||
|
||||
dateStr, err := doc.SelectFirst("#numbers .title-date").Text()
|
||||
dateNode := doc.SelectFirst("#numbers .title-date")
|
||||
if dateNode == nil {
|
||||
return nil, fmt.Errorf("failed to find date element")
|
||||
}
|
||||
|
||||
dateStr, err := dateNode.Text()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get date text: %w", err)
|
||||
}
|
||||
|
||||
drawing.Date, err = time.Parse("Mon, Jan 2, 2006", dateStr)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse date %q: %w", dateStr, err)
|
||||
}
|
||||
|
||||
nums := doc.Select("div.game-ball-group div.white-balls")
|
||||
|
||||
@@ -165,22 +176,12 @@ func getNextDrawing(_ context.Context, doc extractor.Document) (*NextDrawing, er
|
||||
|
||||
numeric := numericOnly(txt)
|
||||
|
||||
set := false
|
||||
if strings.Contains(txt, "Billion") {
|
||||
amt := numeric * 1000000000
|
||||
nextDrawing.JackpotDollars = int(amt)
|
||||
set = true
|
||||
nextDrawing.JackpotDollars = int(numeric * 1000000000)
|
||||
} else if strings.Contains(txt, "Million") {
|
||||
amt := numeric * 1000000
|
||||
nextDrawing.JackpotDollars = int(amt)
|
||||
set = true
|
||||
nextDrawing.JackpotDollars = int(numeric * 1000000)
|
||||
} else {
|
||||
nextDrawing.JackpotDollars = int(numeric)
|
||||
set = true
|
||||
}
|
||||
|
||||
if !set {
|
||||
return nil, fmt.Errorf("failed to convert jackpot to currency: %w", err)
|
||||
}
|
||||
|
||||
return &nextDrawing, nil
|
||||
|
||||
Reference in New Issue
Block a user