blob: e3a1da205bfeabfe07f67144a9bb39604d7aaa6a [file] [log] [blame]
Giorgi Lekveishvilie58fc592023-12-07 13:24:07 +04001package controllers
2
3import (
4 "strings"
5 "testing"
6
7 "os"
8)
9
10const sample = `
11example.com. IN SOA ns1.example.com. hostmaster.example.com. 2015082541 7200 3600 1209600 3600
12ns1.example.com. 10800 IN A 10.1.0.1
13ns2.example.com. 10800 IN A 10.1.0.2
14@.example.com. 10800 IN A 10.1.0.1
15@.example.com. 10800 IN A 10.1.0.2
16*.example.com. 10800 IN CNAME example.com.
17p.example.com. 10800 IN CNAME example.com.
18*.p.example.com. 10800 IN A 10.0.0.1
19`
20
21func TestRead(t *testing.T) {
22 z, err := NewZoneFile(strings.NewReader(sample))
23 if err != nil {
24 t.Fatal(err)
25 }
26 z.CreateOrReplaceTxtRecord("foo.example.com.", "bar")
27 z.DeleteTxtRecord("foo.example.com.", "bar")
28 if err := z.Write(os.Stdout); err != nil {
29 t.Fatal(err)
30 }
31}