mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2026-01-03 06:44:18 +08:00
# Issue Fixes https://github.com/StackExchange/dnscontrol/issues/3912 # Resolution ``` #!/bin/sh # Reset git fetch origin main git reset --hard origin/main git checkout main git branch -D tlim_moveproviders git checkout -b tlim_moveproviders find . -name \*.bak -delete # Move the *.go files out of providers/ mkdir -p pkg/providers git mv providers/*.go pkg/providers # move the _all file out of providers/ git mv providers/_all pkg/providers/_all # Update the imports (in go.* and the affected files) sed -i.bak -e 's@"github.com/StackExchange/dnscontrol/v4/providers"@"github.com/StackExchange/dnscontrol/v4/pkg/providers"@g' go.* $(fgrep -lr --include '*.go' '"github.com/StackExchange/dnscontrol/v4/providers"' *) sed -i.bak -e 's@"../../providers"@"../../pkg/providers"@g' pkg/normalize/capabilities_test.go sed -i.bak -e 's@"github.com/StackExchange/dnscontrol/v4/providers/_all"@"github.com/StackExchange/dnscontrol/v4/pkg/providers/_all"@g' go.* $(fgrep -lr --include '*.go' '"github.com/StackExchange/dnscontrol/v4/providers/_all"' *) # Fix the docs sed -i.bak -e 's@StackExchange/dnscontrol/blob/main/providers/_all/all.go@StackExchange/dnscontrol/blob/main/pkg/providers/_all/all.go@g' documentation/advanced-features/writing-providers.md sed -i.bak -e 's@StackExchange/dnscontrol/providers@StackExchange/dnscontrol/pkg/providers@g' documentation/advanced-features/writing-providers.md sed -i.bak -e 's@StackExchange/dnscontrol/v4/providers@StackExchange/dnscontrol/v4/pkg/providers@g' documentation/advanced-features/writing-providers.md sed -i.bak -e 's@dnscontrol/providers/providers.go@dnscontrol/pkg/providers/providers.go@g' documentation/advanced-features/writing-providers.md sed -i.bak -e 's@providers/_all/all.go@pkg/providers/_all/all.go@g' documentation/advanced-features/writing-providers.md #sed -i.bak -e 's@@@g' documentation/advanced-features/writing-providers.md #sed -i.bak -e 's@@@g' documentation/advanced-features/writing-providers.md find . -name \*.bak -delete go fmt ./... git status echo git commit -a -m'CHORE: Move Non-provider files in providers to pkg/providers' ```
136 lines
3.7 KiB
Go
136 lines
3.7 KiB
Go
package commands
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/StackExchange/dnscontrol/v4/models"
|
|
_ "github.com/StackExchange/dnscontrol/v4/pkg/providers/_all"
|
|
)
|
|
|
|
func TestR53Test_1(t *testing.T) {
|
|
rec := models.RecordConfig{
|
|
Type: "R53_ALIAS",
|
|
Name: "foo",
|
|
NameFQDN: "foo.domain.tld",
|
|
}
|
|
rec.MustSetTarget("bar")
|
|
rec.R53Alias = make(map[string]string)
|
|
rec.R53Alias["type"] = "A"
|
|
w := `R53_ALIAS("foo", "A", "bar")`
|
|
if g := makeR53alias(&rec, 0); g != w {
|
|
t.Errorf("makeR53alias failure: got `%s` want `%s`", g, w)
|
|
}
|
|
}
|
|
|
|
func TestR53Test_1ttl(t *testing.T) {
|
|
rec := models.RecordConfig{
|
|
Type: "R53_ALIAS",
|
|
Name: "foo",
|
|
NameFQDN: "foo.domain.tld",
|
|
}
|
|
rec.MustSetTarget("bar")
|
|
rec.R53Alias = make(map[string]string)
|
|
rec.R53Alias["type"] = "A"
|
|
w := `R53_ALIAS("foo", "A", "bar", TTL(321))`
|
|
if g := makeR53alias(&rec, 321); g != w {
|
|
t.Errorf("makeR53alias failure: got `%s` want `%s`", g, w)
|
|
}
|
|
}
|
|
|
|
func TestR53Test_2(t *testing.T) {
|
|
rec := models.RecordConfig{
|
|
Type: "R53_ALIAS",
|
|
Name: "foo",
|
|
NameFQDN: "foo.domain.tld",
|
|
}
|
|
rec.MustSetTarget("bar")
|
|
rec.R53Alias = make(map[string]string)
|
|
rec.R53Alias["type"] = "A"
|
|
rec.R53Alias["zone_id"] = "blarg"
|
|
w := `R53_ALIAS("foo", "A", "bar", R53_ZONE("blarg"))`
|
|
if g := makeR53alias(&rec, 0); g != w {
|
|
t.Errorf("makeR53alias failure: got `%s` want `%s`", g, w)
|
|
}
|
|
}
|
|
|
|
func TestR53Test_2ttl(t *testing.T) {
|
|
rec := models.RecordConfig{
|
|
Type: "R53_ALIAS",
|
|
Name: "foo",
|
|
NameFQDN: "foo.domain.tld",
|
|
}
|
|
rec.MustSetTarget("bar")
|
|
rec.R53Alias = make(map[string]string)
|
|
rec.R53Alias["type"] = "A"
|
|
rec.R53Alias["zone_id"] = "blarg"
|
|
w := `R53_ALIAS("foo", "A", "bar", R53_ZONE("blarg"), TTL(123))`
|
|
if g := makeR53alias(&rec, 123); g != w {
|
|
t.Errorf("makeR53alias failure: got `%s` want `%s`", g, w)
|
|
}
|
|
}
|
|
|
|
func TestR53Test_3(t *testing.T) {
|
|
rec := models.RecordConfig{
|
|
Type: "R53_ALIAS",
|
|
Name: "foo",
|
|
NameFQDN: "foo.domain.tld",
|
|
}
|
|
rec.MustSetTarget("bar")
|
|
rec.R53Alias = make(map[string]string)
|
|
rec.R53Alias["type"] = "A"
|
|
rec.R53Alias["evaluate_target_health"] = "true"
|
|
w := `R53_ALIAS("foo", "A", "bar", R53_EVALUATE_TARGET_HEALTH(true))`
|
|
if g := makeR53alias(&rec, 0); g != w {
|
|
t.Errorf("makeR53alias failure: got `%s` want `%s`", g, w)
|
|
}
|
|
}
|
|
|
|
func TestR53Test_3ttl(t *testing.T) {
|
|
rec := models.RecordConfig{
|
|
Type: "R53_ALIAS",
|
|
Name: "foo",
|
|
NameFQDN: "foo.domain.tld",
|
|
}
|
|
rec.MustSetTarget("bar")
|
|
rec.R53Alias = make(map[string]string)
|
|
rec.R53Alias["type"] = "A"
|
|
rec.R53Alias["evaluate_target_health"] = "true"
|
|
w := `R53_ALIAS("foo", "A", "bar", R53_EVALUATE_TARGET_HEALTH(true), TTL(123))`
|
|
if g := makeR53alias(&rec, 123); g != w {
|
|
t.Errorf("makeR53alias failure: got `%s` want `%s`", g, w)
|
|
}
|
|
}
|
|
|
|
func TestR53Test_4(t *testing.T) {
|
|
rec := models.RecordConfig{
|
|
Type: "R53_ALIAS",
|
|
Name: "foo",
|
|
NameFQDN: "foo.domain.tld",
|
|
}
|
|
rec.MustSetTarget("bar")
|
|
rec.R53Alias = make(map[string]string)
|
|
rec.R53Alias["type"] = "A"
|
|
rec.R53Alias["zone_id"] = "blarg"
|
|
rec.R53Alias["evaluate_target_health"] = "true"
|
|
w := `R53_ALIAS("foo", "A", "bar", R53_ZONE("blarg"), R53_EVALUATE_TARGET_HEALTH(true))`
|
|
if g := makeR53alias(&rec, 0); g != w {
|
|
t.Errorf("makeR53alias failure: got `%s` want `%s`", g, w)
|
|
}
|
|
}
|
|
|
|
func TestR53Test_4ttl(t *testing.T) {
|
|
rec := models.RecordConfig{
|
|
Type: "R53_ALIAS",
|
|
Name: "foo",
|
|
NameFQDN: "foo.domain.tld",
|
|
}
|
|
rec.MustSetTarget("bar")
|
|
rec.R53Alias = make(map[string]string)
|
|
rec.R53Alias["type"] = "A"
|
|
rec.R53Alias["zone_id"] = "blarg"
|
|
rec.R53Alias["evaluate_target_health"] = "true"
|
|
w := `R53_ALIAS("foo", "A", "bar", R53_ZONE("blarg"), R53_EVALUATE_TARGET_HEALTH(true), TTL(123))`
|
|
if g := makeR53alias(&rec, 123); g != w {
|
|
t.Errorf("makeR53alias failure: got `%s` want `%s`", g, w)
|
|
}
|
|
}
|