diff --git a/docs/index.md b/docs/index.md index 214225285..0e994f7e2 100644 --- a/docs/index.md +++ b/docs/index.md @@ -11,10 +11,12 @@ Dnscontrol is a platform for seamlessly managing your dns configuration across a ## [Language Reference]({{site.github.url}}/js): Description of the DNSControl language (DSL). -## [Examples]({{site.github.url}}/examples): DSL examples. +## [Examples]({{site.github.url}}/examples): The DNSControl language by example. ## [Migrating]({{site.github.url}}/migrating): Migrating zones to DNSControl. +## [Testing]({{site.github.url}}/unittests): Unit Testing DNS Data. + ## [github](https://github.com/StackExchange/dnscontrol): Get the source! diff --git a/docs/unittests.md b/docs/unittests.md new file mode 100644 index 000000000..5023aeeb8 --- /dev/null +++ b/docs/unittests.md @@ -0,0 +1,33 @@ +# Unit Testing DNS Data + +## Testing + +DNSControl performs a number of tests during the validation stage. +You can find them in `pkg/normalize/validate.go`. + + +## External tests + +Tests specific to your environment may be added as external tests. +Output the intermediate representation as a JSON file and perform +tests on this data. + +Output the intermediate representation: + + dnscontrol -debugjson foo.json print + +Here is a sample test written in `bash` using the [jq](https://stedolan.github.io/jq/) command. This fails if the number of MX records in the `stackex.com` domain is not exactly 5: + + COUNTMX=$(jq --raw-output