| Giorgi Lekveishvili | e58fc59 | 2023-12-07 13:24:07 +0400 | [diff] [blame] | 1 | package controllers |
| 2 | |
| 3 | import ( |
| 4 | "strings" |
| 5 | "testing" |
| 6 | |
| 7 | "os" |
| 8 | ) |
| 9 | |
| 10 | const sample = ` |
| 11 | example.com. IN SOA ns1.example.com. hostmaster.example.com. 2015082541 7200 3600 1209600 3600 |
| 12 | ns1.example.com. 10800 IN A 10.1.0.1 |
| 13 | ns2.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. |
| 17 | p.example.com. 10800 IN CNAME example.com. |
| 18 | *.p.example.com. 10800 IN A 10.0.0.1 |
| 19 | ` |
| 20 | |
| 21 | func 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 | } |