dnscontrol/providers/vultr/convert_test.go
Patrick Gaskin 2f83aa9302 Internals: Switch to v2 go.mod, drop GOPATH, and fix Azure Pipelines (#595)
* Switched to v2 go.mod

Also set GO111MODULE=on in build stuff to always use Go modules
even when in GOPATH.

* Ensure go.mod, go.sum, and vendor are up to date

* Attempt to fix Azure pipelines

* Add set -e to properly fail on exit (it didn't seem to be
  propagating properly before).
* Set workingDirectory for GoFmt and GoGen (this might be why it
  fails unlike compile and unitests).

* Another attempt to fix Azure Pipelines

* Use the Go env template for all go-related jobs.

* Completely fixed Azure Pipelines

* Added a display name to GoFmt for consistency.
* Fixed diffs for GoFmt and GoGen.
* Show git status for checks.

* Drop GOPATH for tests

TODO: Do the same for integration tests.

* Drop GOPATH for integration tests

* Show more diffs

* Regenerate provider support matrix

This wasn't done in #590...
2020-01-28 10:42:31 -05:00

73 lines
1.3 KiB
Go

package vultr
import (
"testing"
"github.com/StackExchange/dnscontrol/v2/models"
"github.com/vultr/govultr"
)
func TestConversion(t *testing.T) {
dc := &models.DomainConfig{
Name: "example.com",
}
records := []*govultr.DNSRecord{
{
Type: "A",
Name: "",
Data: "127.0.0.1",
TTL: 300,
},
{
Type: "CNAME",
Name: "*",
Data: "example.com",
TTL: 300,
},
{
Type: "SRV",
Name: "_ssh_.tcp",
Data: "5 22 ssh.example.com",
Priority: 5,
TTL: 300,
},
{
Type: "MX",
Name: "",
Data: "mail.example.com",
TTL: 300,
},
{
Type: "NS",
Name: "",
Data: "ns1.example.net",
TTL: 300,
},
{
Type: "TXT",
Name: "test",
Data: "\"testasd asda sdas dasd\"",
TTL: 300,
},
{
Type: "CAA",
Name: "testasd",
Data: "0 issue \"test.example.net\"",
TTL: 300,
},
}
for _, record := range records {
rc, err := toRecordConfig(dc, record)
if err != nil {
t.Error("Error converting Vultr record", record)
}
converted := toVultrRecord(dc, rc, 0)
if converted.Type != record.Type || converted.Name != record.Name || converted.Data != record.Data || converted.Priority != record.Priority || converted.TTL != record.TTL {
t.Error("Vultr record conversion mismatch", record, rc, converted)
}
}
}