Browse Source

fix existing tests

tags/v3.1.1
Chris Wiegman 5 months ago
parent
commit
086e625818
Signed by: chriswiegman <chris@chriswiegman.com> GPG Key ID: 2B23D7A74FDE2DF4
1 changed files with 11 additions and 6 deletions
  1. +11
    -6
      hostsFile_test.go

+ 11
- 6
hostsFile_test.go View File

@@ -38,19 +38,20 @@ func TestHostsAddWhenIpHasOtherHosts(t *testing.T) {
hosts.FileLines = []HostsLine{
NewHostsLine("127.0.0.1 yadda"),
NewHostsLine("10.0.0.7 nada"),
NewHostsLine("10.0.0.7 yadda"),
}

hosts.Add("10.0.0.7", "", "brada", "yadda")
hosts.Add("10.0.0.7", "", "brada")
hosts.Add("127.0.0.1", "", "yadda")

checkLines := append(hosts.FileLines, hosts.SectionLines...)

expectedLines := []HostsLine{
NewHostsLine("127.0.0.1 yadda"),
NewHostsLine("10.0.0.7 nada"),
NewHostsLine("10.0.0.7 yadda"),
NewHostsLine("10.0.0.7 brada"),
}

if !reflect.DeepEqual(hosts.FileLines, expectedLines) {
if !reflect.DeepEqual(checkLines, expectedLines) {
t.Error("Add entry failed to append entry.")
}
}
@@ -64,6 +65,8 @@ func TestHostsAddWithComment(t *testing.T) {

hosts.Add("10.0.0.7", "Test Comment", "brada", "yadda")

checkLines := append(hosts.FileLines, hosts.SectionLines...)

expectedLines := []HostsLine{
NewHostsLine("127.0.0.1 yadda"),
NewHostsLine("10.0.0.7 nada"),
@@ -71,7 +74,7 @@ func TestHostsAddWithComment(t *testing.T) {
NewHostsLine("10.0.0.7 yadda #Test Comment"),
}

if !reflect.DeepEqual(hosts.FileLines, expectedLines) {
if !reflect.DeepEqual(checkLines, expectedLines) {
t.Error("Add entry failed to append entry.")
}
}
@@ -84,13 +87,15 @@ func TestHostsAddWhenIpDoesntExist(t *testing.T) {

hosts.Add("10.0.0.7", "", "brada", "yadda")

checkLines := append(hosts.FileLines, hosts.SectionLines...)

expectedLines := []HostsLine{
NewHostsLine("127.0.0.1 yadda"),
NewHostsLine("10.0.0.7 brada"),
NewHostsLine("10.0.0.7 yadda"),
}

if !reflect.DeepEqual(hosts.FileLines, expectedLines) {
if !reflect.DeepEqual(checkLines, expectedLines) {
t.Error("Add entry failed to append entry.")
}
}


Loading…
Cancel
Save