Queueing, prepping to fetch

A lot more to go, but this is the core.

Need to think about how to test the queue handlers.
This commit is contained in:
Matt Jadud
2025-11-30 21:29:30 -05:00
parent 06cdc68be7
commit f53639af2f
14 changed files with 258 additions and 105 deletions

View File

@@ -3,16 +3,12 @@ package domain64
import (
"context"
"database/sql"
_ "embed"
"testing"
"github.com/jpillora/go-tld"
_ "modernc.org/sqlite"
)
//go:embed sqlc/schema.sql
var ddl string
func setup() *sql.DB {
ctx := context.Background()
@@ -32,7 +28,8 @@ func setup() *sql.DB {
func TestNewDomain64Map(t *testing.T) {
db := setup()
M, err := NewDomain64Map(db)
M, err := NewDomain64Map()
M.Setup(db)
if err != nil {
// TODO
t.Error(err)
@@ -43,7 +40,8 @@ func TestNewDomain64Map(t *testing.T) {
}
func TestURLToRFQDN(t *testing.T) {
M, _ := NewDomain64Map(nil)
M, _ := NewDomain64Map()
// M.Setup(db)
simple, _ := tld.Parse("https://jadud.com/")
rfqdn := M.URLToRFQDN(simple)
if rfqdn != "com.jadud/" {
@@ -53,7 +51,8 @@ func TestURLToRFQDN(t *testing.T) {
func TestURLToDomain64(t *testing.T) {
db := setup()
M, _ := NewDomain64Map(db)
M, _ := NewDomain64Map()
M.Setup(db)
simple, _ := tld.Parse("https://jadud.com/")
d64, _ := M.URLToDomain64(simple)
if d64.TLD != 1 {
@@ -67,7 +66,8 @@ func TestURLToDomain64(t *testing.T) {
func TestURLToDomain64_02(t *testing.T) {
db := setup()
M, _ := NewDomain64Map(db)
M, _ := NewDomain64Map()
M.Setup(db)
simple1, _ := tld.Parse("https://jadud.com/")
simple2, _ := tld.Parse("https://another.com/")
d64_1, _ := M.URLToDomain64(simple1)
@@ -93,7 +93,8 @@ func TestURLToDomain64_02(t *testing.T) {
func TestURLToDomain64_03(t *testing.T) {
db := setup()
M, _ := NewDomain64Map(db)
M, _ := NewDomain64Map()
M.Setup(db)
var tests = []struct {
url string
tld int64