mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
"Target" RecordConfig should not be exported (#1061)
* Unexport RecordConfig.Target * Fix tests * HEDNS: Fix usage of target field to resolve TXT handling (#1067) Co-authored-by: Robert Blenkinsopp <robert@blenkinsopp.net>
This commit is contained in:
@@ -495,24 +495,24 @@ func (a *azurednsProvider) recordToNative(recordKey models.RecordKey, recordConf
|
||||
if recordSet.ARecords == nil {
|
||||
recordSet.ARecords = &[]adns.ARecord{}
|
||||
}
|
||||
*recordSet.ARecords = append(*recordSet.ARecords, adns.ARecord{Ipv4Address: to.StringPtr(rec.Target)})
|
||||
*recordSet.ARecords = append(*recordSet.ARecords, adns.ARecord{Ipv4Address: to.StringPtr(rec.GetTargetField())})
|
||||
case "AAAA":
|
||||
if recordSet.AaaaRecords == nil {
|
||||
recordSet.AaaaRecords = &[]adns.AaaaRecord{}
|
||||
}
|
||||
*recordSet.AaaaRecords = append(*recordSet.AaaaRecords, adns.AaaaRecord{Ipv6Address: to.StringPtr(rec.Target)})
|
||||
*recordSet.AaaaRecords = append(*recordSet.AaaaRecords, adns.AaaaRecord{Ipv6Address: to.StringPtr(rec.GetTargetField())})
|
||||
case "CNAME":
|
||||
recordSet.CnameRecord = &adns.CnameRecord{Cname: to.StringPtr(rec.Target)}
|
||||
recordSet.CnameRecord = &adns.CnameRecord{Cname: to.StringPtr(rec.GetTargetField())}
|
||||
case "NS":
|
||||
if recordSet.NsRecords == nil {
|
||||
recordSet.NsRecords = &[]adns.NsRecord{}
|
||||
}
|
||||
*recordSet.NsRecords = append(*recordSet.NsRecords, adns.NsRecord{Nsdname: to.StringPtr(rec.Target)})
|
||||
*recordSet.NsRecords = append(*recordSet.NsRecords, adns.NsRecord{Nsdname: to.StringPtr(rec.GetTargetField())})
|
||||
case "PTR":
|
||||
if recordSet.PtrRecords == nil {
|
||||
recordSet.PtrRecords = &[]adns.PtrRecord{}
|
||||
}
|
||||
*recordSet.PtrRecords = append(*recordSet.PtrRecords, adns.PtrRecord{Ptrdname: to.StringPtr(rec.Target)})
|
||||
*recordSet.PtrRecords = append(*recordSet.PtrRecords, adns.PtrRecord{Ptrdname: to.StringPtr(rec.GetTargetField())})
|
||||
case "TXT":
|
||||
if recordSet.TxtRecords == nil {
|
||||
recordSet.TxtRecords = &[]adns.TxtRecord{}
|
||||
@@ -525,20 +525,20 @@ func (a *azurednsProvider) recordToNative(recordKey models.RecordKey, recordConf
|
||||
if recordSet.MxRecords == nil {
|
||||
recordSet.MxRecords = &[]adns.MxRecord{}
|
||||
}
|
||||
*recordSet.MxRecords = append(*recordSet.MxRecords, adns.MxRecord{Exchange: to.StringPtr(rec.Target), Preference: to.Int32Ptr(int32(rec.MxPreference))})
|
||||
*recordSet.MxRecords = append(*recordSet.MxRecords, adns.MxRecord{Exchange: to.StringPtr(rec.GetTargetField()), Preference: to.Int32Ptr(int32(rec.MxPreference))})
|
||||
case "SRV":
|
||||
if recordSet.SrvRecords == nil {
|
||||
recordSet.SrvRecords = &[]adns.SrvRecord{}
|
||||
}
|
||||
*recordSet.SrvRecords = append(*recordSet.SrvRecords, adns.SrvRecord{Target: to.StringPtr(rec.Target), Port: to.Int32Ptr(int32(rec.SrvPort)), Weight: to.Int32Ptr(int32(rec.SrvWeight)), Priority: to.Int32Ptr(int32(rec.SrvPriority))})
|
||||
*recordSet.SrvRecords = append(*recordSet.SrvRecords, adns.SrvRecord{Target: to.StringPtr(rec.GetTargetField()), Port: to.Int32Ptr(int32(rec.SrvPort)), Weight: to.Int32Ptr(int32(rec.SrvWeight)), Priority: to.Int32Ptr(int32(rec.SrvPriority))})
|
||||
case "CAA":
|
||||
if recordSet.CaaRecords == nil {
|
||||
recordSet.CaaRecords = &[]adns.CaaRecord{}
|
||||
}
|
||||
*recordSet.CaaRecords = append(*recordSet.CaaRecords, adns.CaaRecord{Value: to.StringPtr(rec.Target), Tag: to.StringPtr(rec.CaaTag), Flags: to.Int32Ptr(int32(rec.CaaFlag))})
|
||||
*recordSet.CaaRecords = append(*recordSet.CaaRecords, adns.CaaRecord{Value: to.StringPtr(rec.GetTargetField()), Tag: to.StringPtr(rec.CaaTag), Flags: to.Int32Ptr(int32(rec.CaaFlag))})
|
||||
case "AZURE_ALIAS_A", "AZURE_ALIAS_AAAA", "AZURE_ALIAS_CNAME":
|
||||
*recordSet.Type = rec.AzureAlias["type"]
|
||||
recordSet.TargetResource = &adns.SubResource{ID: to.StringPtr(rec.Target)}
|
||||
recordSet.TargetResource = &adns.SubResource{ID: to.StringPtr(rec.GetTargetField())}
|
||||
default:
|
||||
return nil, adns.A, fmt.Errorf("rc.String rtype %v unimplemented", recordKey.Type) // ands.A is a placeholder
|
||||
}
|
||||
|
@@ -8,6 +8,11 @@ import (
|
||||
"github.com/StackExchange/dnscontrol/v3/models"
|
||||
)
|
||||
|
||||
func mkRC(target string, rec *models.RecordConfig) *models.RecordConfig {
|
||||
rec.SetTarget(target)
|
||||
return rec
|
||||
}
|
||||
|
||||
func Test_makeSoa(t *testing.T) {
|
||||
origin := "example.com"
|
||||
var tests = []struct {
|
||||
@@ -20,58 +25,58 @@ func Test_makeSoa(t *testing.T) {
|
||||
{
|
||||
// If everything is blank, the hard-coded defaults should kick in.
|
||||
&SoaInfo{"", "", 0, 0, 0, 0, 0, models.DefaultTTL},
|
||||
&models.RecordConfig{Target: "", SoaMbox: "", SoaSerial: 0, SoaRefresh: 0, SoaRetry: 0, SoaExpire: 0, SoaMinttl: 0},
|
||||
&models.RecordConfig{Target: "", SoaMbox: "", SoaSerial: 0, SoaRefresh: 0, SoaRetry: 0, SoaExpire: 0, SoaMinttl: 0},
|
||||
&models.RecordConfig{Target: "DEFAULT_NOT_SET.", SoaMbox: "DEFAULT_NOT_SET.", SoaSerial: 1, SoaRefresh: 3600, SoaRetry: 600, SoaExpire: 604800, SoaMinttl: 1440},
|
||||
mkRC("", &models.RecordConfig{SoaMbox: "", SoaSerial: 0, SoaRefresh: 0, SoaRetry: 0, SoaExpire: 0, SoaMinttl: 0}),
|
||||
mkRC("", &models.RecordConfig{SoaMbox: "", SoaSerial: 0, SoaRefresh: 0, SoaRetry: 0, SoaExpire: 0, SoaMinttl: 0}),
|
||||
mkRC("DEFAULT_NOT_SET.", &models.RecordConfig{SoaMbox: "DEFAULT_NOT_SET.", SoaSerial: 1, SoaRefresh: 3600, SoaRetry: 600, SoaExpire: 604800, SoaMinttl: 1440}),
|
||||
2019022300,
|
||||
},
|
||||
{
|
||||
// If everything is filled, leave the desired values in place.
|
||||
&SoaInfo{"ns.example.com", "root.example.com", 1, 2, 3, 4, 5, models.DefaultTTL},
|
||||
&models.RecordConfig{Target: "a", SoaMbox: "aa", SoaSerial: 10, SoaRefresh: 11, SoaRetry: 12, SoaExpire: 13, SoaMinttl: 14},
|
||||
&models.RecordConfig{Target: "b", SoaMbox: "bb", SoaSerial: 15, SoaRefresh: 16, SoaRetry: 17, SoaExpire: 18, SoaMinttl: 19},
|
||||
&models.RecordConfig{Target: "b", SoaMbox: "bb", SoaSerial: 15, SoaRefresh: 16, SoaRetry: 17, SoaExpire: 18, SoaMinttl: 19},
|
||||
mkRC("a", &models.RecordConfig{SoaMbox: "aa", SoaSerial: 10, SoaRefresh: 11, SoaRetry: 12, SoaExpire: 13, SoaMinttl: 14}),
|
||||
mkRC("b", &models.RecordConfig{SoaMbox: "bb", SoaSerial: 15, SoaRefresh: 16, SoaRetry: 17, SoaExpire: 18, SoaMinttl: 19}),
|
||||
mkRC("b", &models.RecordConfig{SoaMbox: "bb", SoaSerial: 15, SoaRefresh: 16, SoaRetry: 17, SoaExpire: 18, SoaMinttl: 19}),
|
||||
2019022300,
|
||||
},
|
||||
{
|
||||
// Test incrementing serial.
|
||||
&SoaInfo{"ns.example.com", "root.example.com", 1, 2, 3, 4, 5, models.DefaultTTL},
|
||||
&models.RecordConfig{Target: "a", SoaMbox: "aa", SoaSerial: 2019022301, SoaRefresh: 11, SoaRetry: 12, SoaExpire: 13, SoaMinttl: 14},
|
||||
&models.RecordConfig{Target: "b", SoaMbox: "bb", SoaSerial: 0, SoaRefresh: 16, SoaRetry: 17, SoaExpire: 18, SoaMinttl: 19},
|
||||
&models.RecordConfig{Target: "b", SoaMbox: "bb", SoaSerial: 2019022301, SoaRefresh: 16, SoaRetry: 17, SoaExpire: 18, SoaMinttl: 19},
|
||||
mkRC("a", &models.RecordConfig{SoaMbox: "aa", SoaSerial: 2019022301, SoaRefresh: 11, SoaRetry: 12, SoaExpire: 13, SoaMinttl: 14}),
|
||||
mkRC("b", &models.RecordConfig{SoaMbox: "bb", SoaSerial: 0, SoaRefresh: 16, SoaRetry: 17, SoaExpire: 18, SoaMinttl: 19}),
|
||||
mkRC("b", &models.RecordConfig{SoaMbox: "bb", SoaSerial: 2019022301, SoaRefresh: 16, SoaRetry: 17, SoaExpire: 18, SoaMinttl: 19}),
|
||||
2019022302,
|
||||
},
|
||||
{
|
||||
// Test incrementing serial_2.
|
||||
&SoaInfo{"ns.example.com", "root.example.com", 1, 2, 3, 4, 5, models.DefaultTTL},
|
||||
&models.RecordConfig{Target: "a", SoaMbox: "aa", SoaSerial: 0, SoaRefresh: 11, SoaRetry: 12, SoaExpire: 13, SoaMinttl: 14},
|
||||
&models.RecordConfig{Target: "b", SoaMbox: "bb", SoaSerial: 2019022304, SoaRefresh: 16, SoaRetry: 17, SoaExpire: 18, SoaMinttl: 19},
|
||||
&models.RecordConfig{Target: "b", SoaMbox: "bb", SoaSerial: 2019022304, SoaRefresh: 16, SoaRetry: 17, SoaExpire: 18, SoaMinttl: 19},
|
||||
mkRC("a", &models.RecordConfig{SoaMbox: "aa", SoaSerial: 0, SoaRefresh: 11, SoaRetry: 12, SoaExpire: 13, SoaMinttl: 14}),
|
||||
mkRC("b", &models.RecordConfig{SoaMbox: "bb", SoaSerial: 2019022304, SoaRefresh: 16, SoaRetry: 17, SoaExpire: 18, SoaMinttl: 19}),
|
||||
mkRC("b", &models.RecordConfig{SoaMbox: "bb", SoaSerial: 2019022304, SoaRefresh: 16, SoaRetry: 17, SoaExpire: 18, SoaMinttl: 19}),
|
||||
2019022305,
|
||||
},
|
||||
{
|
||||
// If there are gaps in existing or desired, fill in as appropriate.
|
||||
&SoaInfo{"ns.example.com", "root.example.com", 1, 2, 3, 4, 5, models.DefaultTTL},
|
||||
&models.RecordConfig{Target: "", SoaMbox: "aa", SoaSerial: 0, SoaRefresh: 11, SoaRetry: 0, SoaExpire: 13, SoaMinttl: 0},
|
||||
&models.RecordConfig{Target: "b", SoaMbox: "", SoaSerial: 15, SoaRefresh: 0, SoaRetry: 17, SoaExpire: 0, SoaMinttl: 19},
|
||||
&models.RecordConfig{Target: "b", SoaMbox: "aa", SoaSerial: 15, SoaRefresh: 11, SoaRetry: 17, SoaExpire: 13, SoaMinttl: 19},
|
||||
mkRC("", &models.RecordConfig{SoaMbox: "aa", SoaSerial: 0, SoaRefresh: 11, SoaRetry: 0, SoaExpire: 13, SoaMinttl: 0}),
|
||||
mkRC("b", &models.RecordConfig{SoaMbox: "", SoaSerial: 15, SoaRefresh: 0, SoaRetry: 17, SoaExpire: 0, SoaMinttl: 19}),
|
||||
mkRC("b", &models.RecordConfig{SoaMbox: "aa", SoaSerial: 15, SoaRefresh: 11, SoaRetry: 17, SoaExpire: 13, SoaMinttl: 19}),
|
||||
2019022300,
|
||||
},
|
||||
{
|
||||
// Gaps + existing==nil
|
||||
&SoaInfo{"ns.example.com", "root.example.com", 1, 2, 3, 4, 5, models.DefaultTTL},
|
||||
nil,
|
||||
&models.RecordConfig{Target: "b", SoaMbox: "", SoaSerial: 15, SoaRefresh: 0, SoaRetry: 17, SoaExpire: 0, SoaMinttl: 19},
|
||||
&models.RecordConfig{Target: "b", SoaMbox: "root.example.com", SoaSerial: 15, SoaRefresh: 2, SoaRetry: 17, SoaExpire: 4, SoaMinttl: 19},
|
||||
mkRC("b", &models.RecordConfig{SoaMbox: "", SoaSerial: 15, SoaRefresh: 0, SoaRetry: 17, SoaExpire: 0, SoaMinttl: 19}),
|
||||
mkRC("b", &models.RecordConfig{SoaMbox: "root.example.com", SoaSerial: 15, SoaRefresh: 2, SoaRetry: 17, SoaExpire: 4, SoaMinttl: 19}),
|
||||
2019022300,
|
||||
},
|
||||
{
|
||||
// Gaps + desired==nil
|
||||
// NB(tom): In the code as of 2020-02-23, desired will never be nil.
|
||||
&SoaInfo{"ns.example.com", "root.example.com", 1, 2, 3, 4, 5, models.DefaultTTL},
|
||||
&models.RecordConfig{Target: "", SoaMbox: "aa", SoaSerial: 0, SoaRefresh: 11, SoaRetry: 0, SoaExpire: 13, SoaMinttl: 0},
|
||||
mkRC("", &models.RecordConfig{SoaMbox: "aa", SoaSerial: 0, SoaRefresh: 11, SoaRetry: 0, SoaExpire: 13, SoaMinttl: 0}),
|
||||
nil,
|
||||
&models.RecordConfig{Target: "ns.example.com", SoaMbox: "aa", SoaSerial: 1, SoaRefresh: 11, SoaRetry: 3, SoaExpire: 13, SoaMinttl: 5},
|
||||
mkRC("ns.example.com", &models.RecordConfig{SoaMbox: "aa", SoaSerial: 1, SoaRefresh: 11, SoaRetry: 3, SoaExpire: 13, SoaMinttl: 5}),
|
||||
2019022300,
|
||||
},
|
||||
}
|
||||
@@ -115,8 +120,8 @@ func areEqualSoa(r1, r2 *models.RecordConfig) bool {
|
||||
fmt.Printf("ERROR: name %q != %q\n", r1.Name, r2.Name)
|
||||
return false
|
||||
}
|
||||
if r1.Target != r2.Target {
|
||||
fmt.Printf("ERROR: target %q != %q\n", r1.Target, r2.Target)
|
||||
if r1.GetTargetField() != r2.GetTargetField() {
|
||||
fmt.Printf("ERROR: target %q != %q\n", r1, r2.GetTargetField())
|
||||
return false
|
||||
}
|
||||
if r1.SoaMbox != r2.SoaMbox {
|
||||
|
@@ -277,7 +277,7 @@ func toReq(rc *models.RecordConfig) (requestParams, error) {
|
||||
case "CAA":
|
||||
req["caa_flag"] = strconv.Itoa(int(rc.CaaFlag))
|
||||
req["caa_type"] = rc.CaaTag
|
||||
req["caa_value"] = rc.Target
|
||||
req["caa_value"] = rc.GetTargetField()
|
||||
case "TLSA":
|
||||
req["tlsa_usage"] = strconv.Itoa(int(rc.TlsaUsage))
|
||||
req["tlsa_selector"] = strconv.Itoa(int(rc.TlsaSelector))
|
||||
|
@@ -162,7 +162,7 @@ func (c *exoscaleProvider) createRecordFunc(rc *models.RecordConfig, domainName
|
||||
name := rc.GetLabel()
|
||||
|
||||
if rc.Type == "MX" {
|
||||
target = rc.Target
|
||||
target = rc.GetTargetField()
|
||||
}
|
||||
|
||||
if rc.Type == "NS" && (name == "@" || name == "") {
|
||||
@@ -210,7 +210,7 @@ func (c *exoscaleProvider) updateRecordFunc(old *egoscale.DNSRecord, rc *models.
|
||||
name := rc.GetLabel()
|
||||
|
||||
if rc.Type == "MX" {
|
||||
target = rc.Target
|
||||
target = rc.GetTargetField()
|
||||
}
|
||||
|
||||
if rc.Type == "NS" && (name == "@" || name == "") {
|
||||
|
@@ -297,7 +297,10 @@ func (c *hednsProvider) GetZoneRecords(domain string) (models.Records, error) {
|
||||
RecordName: parser.parseStringElement(element.Find(".dns_view")),
|
||||
RecordID: parser.parseIntAttr(element, "id"),
|
||||
},
|
||||
Target: parser.parseStringAttr(element.Find("td:nth-child(7)"), "data"),
|
||||
}
|
||||
data := parser.parseStringAttr(element.Find("td:nth-child(7)"), "data")
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
priority := parser.parseIntElement(element.Find("td:nth-child(6)"))
|
||||
@@ -313,24 +316,20 @@ func (c *hednsProvider) GetZoneRecords(domain string) (models.Records, error) {
|
||||
|
||||
rc.SetLabelFromFQDN(rc.Original.(Record).RecordName, domain)
|
||||
|
||||
// dns.he.net omits the trailing "." on the hostnames for certain MX records
|
||||
if rc.Type == "MX" {
|
||||
rc.Target += "."
|
||||
}
|
||||
|
||||
switch rc.Type {
|
||||
case "ALIAS":
|
||||
err = rc.SetTarget(rc.Target)
|
||||
err = rc.SetTarget(data)
|
||||
case "MX":
|
||||
err = rc.SetTargetMX(uint16(priority), rc.Target)
|
||||
// dns.he.net omits the trailing "." on the hostnames for MX records
|
||||
err = rc.SetTargetMX(uint16(priority), data + ".")
|
||||
case "SRV":
|
||||
err = rc.SetTargetSRVPriorityString(uint16(priority), rc.Target)
|
||||
err = rc.SetTargetSRVPriorityString(uint16(priority), data)
|
||||
case "SPF":
|
||||
// Convert to TXT record as SPF is deprecated
|
||||
rc.Type = "TXT"
|
||||
fallthrough
|
||||
default:
|
||||
err = rc.PopulateFromString(rc.Type, rc.Target, domain)
|
||||
err = rc.PopulateFromString(rc.Type, data, domain)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@@ -562,10 +561,10 @@ func (c *hednsProvider) editZoneRecord(rc *models.RecordConfig, create bool) err
|
||||
switch rc.Type {
|
||||
case "MX":
|
||||
values.Set("Priority", strconv.FormatUint(uint64(rc.MxPreference), 10))
|
||||
values.Set("Content", rc.Target)
|
||||
values.Set("Content", rc.GetTargetField())
|
||||
case "SRV":
|
||||
values.Del("Content")
|
||||
values.Set("Target", rc.Target)
|
||||
values.Set("Target", rc.GetTargetField())
|
||||
values.Set("Priority", strconv.FormatUint(uint64(rc.SrvPriority), 10))
|
||||
values.Set("Weight", strconv.FormatUint(uint64(rc.SrvWeight), 10))
|
||||
values.Set("Port", strconv.FormatUint(uint64(rc.SrvPort), 10))
|
||||
|
@@ -245,7 +245,7 @@ func (n *HXClient) createRecordString(rc *models.RecordConfig, domain string) (s
|
||||
case "A", "AAAA", "ANAME", "CNAME", "MX", "NS", "PTR":
|
||||
// nothing
|
||||
case "TLSA":
|
||||
record.Answer = fmt.Sprintf(`%v %v %v %s`, rc.TlsaUsage, rc.TlsaSelector, rc.TlsaMatchingType, rc.Target)
|
||||
record.Answer = fmt.Sprintf(`%v %v %v %s`, rc.TlsaUsage, rc.TlsaSelector, rc.TlsaMatchingType, rc.GetTargetField())
|
||||
case "CAA":
|
||||
record.Answer = fmt.Sprintf(`%v %s "%s"`, rc.CaaFlag, rc.CaaTag, record.Answer)
|
||||
case "TXT":
|
||||
|
@@ -112,28 +112,28 @@ func Test_generatePSZoneDump(t *testing.T) {
|
||||
func Test_generatePSModify(t *testing.T) {
|
||||
|
||||
recA1 := &models.RecordConfig{
|
||||
Type: "A",
|
||||
Name: "@",
|
||||
Target: "1.2.3.4",
|
||||
Type: "A",
|
||||
Name: "@",
|
||||
}
|
||||
recA1.SetTarget("1.2.3.4")
|
||||
recA2 := &models.RecordConfig{
|
||||
Type: "A",
|
||||
Name: "@",
|
||||
Target: "10.20.30.40",
|
||||
Type: "A",
|
||||
Name: "@",
|
||||
}
|
||||
recA2.SetTarget("10.20.30.40")
|
||||
|
||||
recMX1 := &models.RecordConfig{
|
||||
Type: "MX",
|
||||
Name: "@",
|
||||
Target: "foo.com.",
|
||||
MxPreference: 5,
|
||||
}
|
||||
recMX1.SetTarget("foo.com.")
|
||||
recMX2 := &models.RecordConfig{
|
||||
Type: "MX",
|
||||
Name: "@",
|
||||
Target: "foo2.com.",
|
||||
MxPreference: 50,
|
||||
}
|
||||
recMX2.SetTarget("foo2.com.")
|
||||
|
||||
type args struct {
|
||||
domain string
|
||||
|
@@ -132,7 +132,7 @@ func fromRecordConfig(in *models.RecordConfig) *record {
|
||||
rc.Destination = strings.TrimSuffix(in.GetTargetField(), ".")
|
||||
rc.Priority = strconv.Itoa(int(in.MxPreference))
|
||||
case "SRV":
|
||||
rc.Destination = strconv.Itoa(int(in.SrvPriority)) + " " + strconv.Itoa(int(in.SrvWeight)) + " " + strconv.Itoa(int(in.SrvPort)) + " " + in.Target
|
||||
rc.Destination = strconv.Itoa(int(in.SrvPriority)) + " " + strconv.Itoa(int(in.SrvWeight)) + " " + strconv.Itoa(int(in.SrvPort)) + " " + in.GetTargetField()
|
||||
case "CAA":
|
||||
rc.Destination = strconv.Itoa(int(in.CaaFlag)) + " " + in.CaaTag + " \"" + in.GetTargetField() + "\""
|
||||
case "TLSA":
|
||||
|
@@ -18,10 +18,10 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"unicode"
|
||||
|
||||
testifyrequire "github.com/stretchr/testify/require"
|
||||
"github.com/tdewolff/minify"
|
||||
minjson "github.com/tdewolff/minify/json"
|
||||
)
|
||||
@@ -180,11 +180,8 @@ func TestYamlRead(t *testing.T) {
|
||||
//fmt.Printf("DEBUG: EXPECTED=%s\n", string(expectedJSON))
|
||||
//fmt.Printf("DEBUG: ACTUAL =%s\n", string(actualJSON))
|
||||
|
||||
if strings.TrimSpace(string(expectedJSON)) != strings.TrimSpace(string(actualJSON)) {
|
||||
t.Error("Expected and actual json don't match")
|
||||
t.Log("Expected:", string(expectedJSON))
|
||||
t.Log("Actual :", string(actualJSON))
|
||||
}
|
||||
es, as := string(expectedJSON), string(actualJSON)
|
||||
testifyrequire.JSONEqf(t, es, as, "EXPECTING %q = \n```\n%s\n```", expectedFile, as)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user