feat(store): sqlc-запросы, dto TemplateDoc, Repository, интеграционные тесты CRUD
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user