mirror of
https://github.com/notherealmarco/coredns-deployment.git
synced 2025-05-05 20:42:33 +02:00
Alter existing "deprecated" function to return all migration notices (#159)
This commit is contained in:
parent
5960d7facb
commit
709b136563
7 changed files with 19 additions and 122 deletions
|
@ -14,7 +14,7 @@ func TestMigrate(t *testing.T) {
|
|||
expectedCorefile string
|
||||
}{
|
||||
{
|
||||
name: "Remove invalid proxy option",
|
||||
name: "Remove invalid proxy option",
|
||||
fromVersion: "1.1.3",
|
||||
toVersion: "1.2.6",
|
||||
deprecations: true,
|
||||
|
@ -56,7 +56,7 @@ func TestMigrate(t *testing.T) {
|
|||
`,
|
||||
},
|
||||
{
|
||||
name: "Migrate from proxy to forward and handle Kubernetes deprecations",
|
||||
name: "Migrate from proxy to forward and handle Kubernetes deprecations",
|
||||
fromVersion: "1.3.1",
|
||||
toVersion: "1.5.0",
|
||||
deprecations: true,
|
||||
|
@ -96,7 +96,7 @@ func TestMigrate(t *testing.T) {
|
|||
`,
|
||||
},
|
||||
{
|
||||
name: "add missing loop and ready plugins",
|
||||
name: "add missing loop and ready plugins",
|
||||
fromVersion: "1.1.3",
|
||||
toVersion: "1.5.0",
|
||||
deprecations: true,
|
||||
|
@ -132,7 +132,6 @@ func TestMigrate(t *testing.T) {
|
|||
}
|
||||
`,
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
|
@ -155,6 +154,7 @@ func TestDeprecated(t *testing.T) {
|
|||
startCorefile := `.:53 {
|
||||
errors
|
||||
health
|
||||
ready
|
||||
kubernetes cluster.local in-addr.arpa ip6.arpa {
|
||||
pods insecure
|
||||
upstream
|
||||
|
@ -172,48 +172,12 @@ func TestDeprecated(t *testing.T) {
|
|||
expected := []Notice{
|
||||
{Plugin: "kubernetes", Option: "upstream", Severity: deprecated, Version: "1.4.0"},
|
||||
{Plugin: "proxy", Severity: deprecated, ReplacedBy: "forward", Version: "1.4.0"},
|
||||
}
|
||||
|
||||
result, err := Deprecated("1.3.1", "1.5.0", startCorefile)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if len(result) != len(expected) {
|
||||
t.Fatalf("expected to find %v deprecations; got %v", len(expected), len(result))
|
||||
}
|
||||
|
||||
for i, dep := range expected {
|
||||
if result[i].ToString() != dep.ToString() {
|
||||
t.Errorf("expected to get '%v'; got '%v'", dep.ToString(), result[i].ToString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRemoved(t *testing.T) {
|
||||
startCorefile := `.:53 {
|
||||
errors
|
||||
health
|
||||
kubernetes cluster.local in-addr.arpa ip6.arpa {
|
||||
pods insecure
|
||||
upstream
|
||||
fallthrough in-addr.arpa ip6.arpa
|
||||
}
|
||||
prometheus :9153
|
||||
proxy . /etc/resolv.conf
|
||||
cache 30
|
||||
loop
|
||||
reload
|
||||
loadbalance
|
||||
}
|
||||
`
|
||||
|
||||
expected := []Notice{
|
||||
{Plugin: "ready", Severity: newdefault, Version: "1.5.0"},
|
||||
{Option: "upstream", Plugin: "kubernetes", Severity: ignored, Version: "1.5.0"},
|
||||
{Plugin: "proxy", Severity: removed, ReplacedBy: "forward", Version: "1.5.0"},
|
||||
}
|
||||
|
||||
result, err := Removed("1.3.1", "1.5.0", startCorefile)
|
||||
result, err := Deprecated("1.3.1", "1.5.0", startCorefile)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue