Skip to content

Commit

Permalink
remove facebookgo/ensure (facebookincubator#44)
Browse files Browse the repository at this point in the history
Summary:
The lib is deprecated.

Pull Request resolved: facebookincubator#44

Reviewed By: tfg13

Differential Revision: D45728188

fbshipit-source-id: 3f96f1145002ff93d9e66d0149ee7458974a2ef6
  • Loading branch information
pmazzini authored and facebook-github-bot committed May 10, 2023
1 parent be075bc commit e708a18
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 73 deletions.
4 changes: 0 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/facebookincubator/dhcplb
go 1.19

require (
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c
github.com/fsnotify/fsnotify v1.6.0
github.com/golang/glog v1.1.0
github.com/hashicorp/golang-lru/v2 v2.0.2
Expand All @@ -12,9 +11,6 @@ require (
)

require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 // indirect
github.com/josharian/native v1.1.0 // indirect
github.com/pierrec/lz4/v4 v4.1.14 // indirect
github.com/u-root/uio v0.0.0-20230220225925-ffce2a382923 // indirect
Expand Down
8 changes: 0 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0=
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64=
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A=
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg=
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk=
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE=
Expand Down
118 changes: 57 additions & 61 deletions lib/update_servers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,75 +8,71 @@
package dhcplb

import (
"github.com/facebookgo/ensure"
"fmt"
"net"
"reflect"
"testing"
)

func Test_Nil(t *testing.T) {
added, removed := diffServersList(nil, nil)
// added and removed lists should be empty
ensure.DeepEqual(t, added, make([]*DHCPServer, 0))
ensure.DeepEqual(t, removed, make([]*DHCPServer, 0))
}

func UpdateServerTestEmpty(t *testing.T) {
added, removed := diffServersList(make([]*DHCPServer, 0), make([]*DHCPServer, 0))
// added and removed lists should be empty
ensure.DeepEqual(t, added, make([]*DHCPServer, 0))
ensure.DeepEqual(t, removed, make([]*DHCPServer, 0))
}

func Test_Add(t *testing.T) {
var original []*DHCPServer
updated := []*DHCPServer{
&DHCPServer{
Address: net.ParseIP("1.2.3.4"),
Port: 1,
},
&DHCPServer{
Address: net.ParseIP("5.6.7.8"),
Port: 2,
func TestDiffServerList(t *testing.T) {
for i, tt := range []struct {
original []*DHCPServer
updated []*DHCPServer
}{
{
original: []*DHCPServer{},
updated: []*DHCPServer{},
},
}
added, removed := diffServersList(original, updated)
// original list was empty, so added should just be the new list
ensure.DeepEqual(t, added, updated)
ensure.DeepEqual(t, removed, make([]*DHCPServer, 0))
}
{
original: []*DHCPServer{},
updated: []*DHCPServer{

func Test_Remove(t *testing.T) {
original := []*DHCPServer{
&DHCPServer{
Address: net.ParseIP("1.2.3.4"),
Port: 1,
},
&DHCPServer{
Address: net.ParseIP("5.6.7.8"),
Port: 2,
&DHCPServer{
Address: net.ParseIP("1.2.3.4"),
Port: 1,
},
&DHCPServer{
Address: net.ParseIP("5.6.7.8"),
Port: 2,
},
},
},
}
var updated []*DHCPServer
added, removed := diffServersList(original, updated)
// new list is empty, so removed should just be the original list
ensure.DeepEqual(t, removed, original)
ensure.DeepEqual(t, added, make([]*DHCPServer, 0))
}

func Test_Add_Remove(t *testing.T) {
original := []*DHCPServer{
&DHCPServer{
Address: net.ParseIP("1.2.3.4"),
Port: 1,
{
original: []*DHCPServer{
&DHCPServer{
Address: net.ParseIP("1.2.3.4"),
Port: 1,
},
&DHCPServer{
Address: net.ParseIP("5.6.7.8"),
Port: 2,
},
},
updated: []*DHCPServer{},
},
}
updated := []*DHCPServer{
&DHCPServer{
Address: net.ParseIP("5.6.7.8"),
Port: 2,
{
original: []*DHCPServer{
&DHCPServer{
Address: net.ParseIP("1.2.3.4"),
Port: 1,
},
},
updated: []*DHCPServer{
&DHCPServer{
Address: net.ParseIP("5.6.7.8"),
Port: 2,
},
},
},
} {
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
added, removed := diffServersList(tt.original, tt.updated)
if !reflect.DeepEqual(added, tt.updated) {
t.Errorf("added %v, updated %v", added, tt.updated)
}
if !reflect.DeepEqual(removed, tt.original) {
t.Errorf("removed %v, original %v", removed, tt.original)
}
})
}
added, removed := diffServersList(original, updated)
ensure.DeepEqual(t, added, updated)
ensure.DeepEqual(t, removed, original)
}

0 comments on commit e708a18

Please sign in to comment.