mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-02-24 23:53:01 +08:00
deadcode: Change/ChangeList.String
This commit is contained in:
parent
0576cec7d8
commit
798c0d6b9e
4 changed files with 69 additions and 65 deletions
|
@ -1,6 +1,8 @@
|
|||
package diff2
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
@ -18,6 +20,42 @@ func init() {
|
|||
color.NoColor = true
|
||||
}
|
||||
|
||||
// Stringify the datastructures (for debugging)
|
||||
|
||||
func (c Change) String() string {
|
||||
var buf bytes.Buffer
|
||||
b := &buf
|
||||
|
||||
fmt.Fprintf(b, "Change: verb=%v\n", c.Type)
|
||||
fmt.Fprintf(b, " key=%v\n", c.Key)
|
||||
if c.HintOnlyTTL {
|
||||
fmt.Fprint(b, " Hints=OnlyTTL\n", c.Key)
|
||||
}
|
||||
if len(c.Old) != 0 {
|
||||
fmt.Fprintf(b, " old=%v\n", c.Old)
|
||||
}
|
||||
if len(c.New) != 0 {
|
||||
fmt.Fprintf(b, " new=%v\n", c.New)
|
||||
}
|
||||
fmt.Fprintf(b, " msg=%q\n", c.Msgs)
|
||||
|
||||
return b.String()
|
||||
}
|
||||
|
||||
func (cl ChangeList) String() string {
|
||||
var buf bytes.Buffer
|
||||
b := &buf
|
||||
|
||||
fmt.Fprintf(b, "ChangeList: len=%d\n", len(cl))
|
||||
for i, j := range cl {
|
||||
fmt.Fprintf(b, "%02d: %s", i, j)
|
||||
}
|
||||
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// Make sample data
|
||||
|
||||
func makeRec(label, rtype, content string) *models.RecordConfig {
|
||||
origin := "f.com"
|
||||
r := models.RecordConfig{TTL: 300}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package diff2
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
|
@ -171,35 +170,6 @@ func (cc *CompareConfig) verifyCNAMEAssertions() {
|
|||
|
||||
}
|
||||
|
||||
// String returns cc represented as a string. This is used for
|
||||
// debugging and unit tests, as the structure may otherwise be
|
||||
// difficult to compare.
|
||||
func (cc *CompareConfig) String() string {
|
||||
var buf bytes.Buffer
|
||||
b := &buf
|
||||
|
||||
fmt.Fprintf(b, "ldata:\n")
|
||||
for i, ld := range cc.ldata {
|
||||
fmt.Fprintf(b, " ldata[%02d]: %s\n", i, ld.label)
|
||||
for j, t := range ld.tdata {
|
||||
fmt.Fprintf(b, " tdata[%d]: %q e(%d, %d) d(%d, %d)\n", j, t.rType,
|
||||
len(t.existingTargets),
|
||||
len(t.existingRecs),
|
||||
len(t.desiredTargets),
|
||||
len(t.desiredRecs),
|
||||
)
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(b, "labelMap: len=%d %v\n", len(cc.labelMap), cc.labelMap)
|
||||
fmt.Fprintf(b, "keyMap: len=%d %v\n", len(cc.keyMap), cc.keyMap)
|
||||
fmt.Fprintf(b, "existing: %q\n", cc.existing)
|
||||
fmt.Fprintf(b, "desired: %q\n", cc.desired)
|
||||
fmt.Fprintf(b, "origin: %v\n", cc.origin)
|
||||
fmt.Fprintf(b, "compFn: %v\n", cc.compareableFunc)
|
||||
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// Generate a string that can be used to compare this record to others
|
||||
// for equality.
|
||||
func mkCompareBlobs(rc *models.RecordConfig, f func(*models.RecordConfig) string) (string, string) {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package diff2
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
@ -8,6 +10,35 @@ import (
|
|||
"github.com/kylelemons/godebug/diff"
|
||||
)
|
||||
|
||||
// String returns cc represented as a string. This is used for
|
||||
// debugging and unit tests, as the structure may otherwise be
|
||||
// difficult to compare.
|
||||
func (cc *CompareConfig) String() string {
|
||||
var buf bytes.Buffer
|
||||
b := &buf
|
||||
|
||||
fmt.Fprintf(b, "ldata:\n")
|
||||
for i, ld := range cc.ldata {
|
||||
fmt.Fprintf(b, " ldata[%02d]: %s\n", i, ld.label)
|
||||
for j, t := range ld.tdata {
|
||||
fmt.Fprintf(b, " tdata[%d]: %q e(%d, %d) d(%d, %d)\n", j, t.rType,
|
||||
len(t.existingTargets),
|
||||
len(t.existingRecs),
|
||||
len(t.desiredTargets),
|
||||
len(t.desiredRecs),
|
||||
)
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(b, "labelMap: len=%d %v\n", len(cc.labelMap), cc.labelMap)
|
||||
fmt.Fprintf(b, "keyMap: len=%d %v\n", len(cc.keyMap), cc.keyMap)
|
||||
fmt.Fprintf(b, "existing: %q\n", cc.existing)
|
||||
fmt.Fprintf(b, "desired: %q\n", cc.desired)
|
||||
fmt.Fprintf(b, "origin: %v\n", cc.origin)
|
||||
fmt.Fprintf(b, "compFn: %v\n", cc.compareableFunc)
|
||||
|
||||
return b.String()
|
||||
}
|
||||
|
||||
func TestNewCompareConfig(t *testing.T) {
|
||||
type args struct {
|
||||
origin string
|
||||
|
|
|
@ -6,7 +6,6 @@ package diff2
|
|||
// against the desired records.
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
|
@ -255,37 +254,3 @@ func byHelper(fn func(cc *CompareConfig) ChangeList, existing models.Records, dc
|
|||
|
||||
return instructions, nil
|
||||
}
|
||||
|
||||
// Stringify the datastructures (for debugging)
|
||||
|
||||
func (c Change) String() string {
|
||||
var buf bytes.Buffer
|
||||
b := &buf
|
||||
|
||||
fmt.Fprintf(b, "Change: verb=%v\n", c.Type)
|
||||
fmt.Fprintf(b, " key=%v\n", c.Key)
|
||||
if c.HintOnlyTTL {
|
||||
fmt.Fprint(b, " Hints=OnlyTTL\n", c.Key)
|
||||
}
|
||||
if len(c.Old) != 0 {
|
||||
fmt.Fprintf(b, " old=%v\n", c.Old)
|
||||
}
|
||||
if len(c.New) != 0 {
|
||||
fmt.Fprintf(b, " new=%v\n", c.New)
|
||||
}
|
||||
fmt.Fprintf(b, " msg=%q\n", c.Msgs)
|
||||
|
||||
return b.String()
|
||||
}
|
||||
|
||||
func (cl ChangeList) String() string {
|
||||
var buf bytes.Buffer
|
||||
b := &buf
|
||||
|
||||
fmt.Fprintf(b, "ChangeList: len=%d\n", len(cl))
|
||||
for i, j := range cl {
|
||||
fmt.Fprintf(b, "%02d: %s", i, j)
|
||||
}
|
||||
|
||||
return b.String()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue