From 6438c4f4e01e6a5b7f6f3800c2a582a61eb69365 Mon Sep 17 00:00:00 2001 From: Chris O'Haver Date: Fri, 24 Feb 2023 09:48:56 -0500 Subject: [PATCH] Add checks for non-migration case (#75) * check for no migration case * fix non-migration test with unsupported plugin to expect no error Signed-off-by: Chris O'Haver --------- Signed-off-by: Chris O'Haver --- migration/migrate.go | 6 ++++++ migration/migrate_test.go | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/migration/migrate.go b/migration/migrate.go index d0d11a1..38e91a9 100644 --- a/migration/migrate.go +++ b/migration/migrate.go @@ -20,12 +20,18 @@ import ( // any deprecated, removed, or ignored plugins/directives present in the Corefile. Notifications are also returned for // any new default plugins that would be added in a migration. func Deprecated(fromCoreDNSVersion, toCoreDNSVersion, corefileStr string) ([]Notice, error) { + if fromCoreDNSVersion == toCoreDNSVersion { + return nil, nil + } return getStatus(fromCoreDNSVersion, toCoreDNSVersion, corefileStr, SevAll) } // Unsupported returns a list notifications of plugins/options that are not handled supported by this migration tool, // but may still be valid in CoreDNS. func Unsupported(fromCoreDNSVersion, toCoreDNSVersion, corefileStr string) ([]Notice, error) { + if fromCoreDNSVersion == toCoreDNSVersion { + return nil, nil + } return getStatus(fromCoreDNSVersion, toCoreDNSVersion, corefileStr, SevUnsupported) } diff --git a/migration/migrate_test.go b/migration/migrate_test.go index fedce1f..1d71453 100644 --- a/migration/migrate_test.go +++ b/migration/migrate_test.go @@ -858,9 +858,7 @@ func TestUnsupported(t *testing.T) { `, fromVersion: "1.3.1", toVersion: "1.3.1", - expected: []Notice{ - {Plugin: "route53", Severity: SevUnsupported, Version: "1.3.1"}, - }, + expected: []Notice{}, }, { name: "Wrong plugin option",