feat(store): sqlc-запросы, dto TemplateDoc, Repository, интеграционные тесты CRUD

This commit is contained in:
2026-07-03 14:08:37 +07:00
parent 9c29d40269
commit 34bc49ee8c
15 changed files with 757 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
package dto
import (
"testing"
"github.com/vasyakrg/dns-autoresolver/internal/model"
)
func TestTemplateDocRoundTrip(t *testing.T) {
recs := []model.Record{
{Type: model.A, Name: "www.example.com.", TTL: 300, Values: []string{"1.2.3.4"}},
{Type: model.MX, Name: "example.com.", TTL: 3600, Values: []string{"10 mx1.example.com."}},
}
doc := FromModel(recs)
if len(doc.Records) != 2 {
t.Fatalf("want 2 records, got %d", len(doc.Records))
}
back := doc.ToModel()
if len(back) != 2 || back[0].Type != model.A || back[1].Type != model.MX {
t.Fatalf("round-trip mismatch: %+v", back)
}
if back[0].Values[0] != "1.2.3.4" || back[1].TTL != 3600 {
t.Fatalf("field mismatch: %+v", back)
}
}