mirror of
https://github.com/bakito/adguardhome-sync.git
synced 2025-01-01 04:41:51 +08:00
fix dhcp clone function #149
This commit is contained in:
parent
6d08d42626
commit
49f301589d
3 changed files with 63 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,3 +6,4 @@ main
|
|||
.adguardhome-sync.yaml
|
||||
tmp
|
||||
bin
|
||||
config.yaml
|
||||
|
|
|
@ -22,7 +22,7 @@ type DHCPServerConfig struct {
|
|||
// Clone the config
|
||||
func (c *DHCPServerConfig) Clone() *DHCPServerConfig {
|
||||
clone := &DHCPServerConfig{}
|
||||
_ = copier.Copy(c, clone)
|
||||
_ = copier.Copy(clone, c)
|
||||
return clone
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package types_test
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net"
|
||||
"os"
|
||||
|
||||
"github.com/bakito/adguardhome-sync/pkg/types"
|
||||
|
@ -360,4 +361,64 @@ var _ = Describe("Types", func() {
|
|||
})
|
||||
})
|
||||
})
|
||||
Context("DHCPServerConfig", func() {
|
||||
Context("Equals", func() {
|
||||
It("should be equal", func() {
|
||||
dc1 := &types.DHCPServerConfig{
|
||||
V4: &types.V4ServerConfJSON{
|
||||
GatewayIP: net.IPv4(1, 2, 3, 4),
|
||||
LeaseDuration: 123,
|
||||
RangeStart: net.IPv4(1, 2, 3, 5),
|
||||
RangeEnd: net.IPv4(1, 2, 3, 6),
|
||||
SubnetMask: net.IPv4(255, 255, 255, 0),
|
||||
},
|
||||
}
|
||||
dc2 := &types.DHCPServerConfig{
|
||||
V4: &types.V4ServerConfJSON{
|
||||
GatewayIP: net.IPv4(1, 2, 3, 4),
|
||||
LeaseDuration: 123,
|
||||
RangeStart: net.IPv4(1, 2, 3, 5),
|
||||
RangeEnd: net.IPv4(1, 2, 3, 6),
|
||||
SubnetMask: net.IPv4(255, 255, 255, 0),
|
||||
},
|
||||
}
|
||||
Ω(dc1.Equals(dc2)).Should(BeTrue())
|
||||
})
|
||||
It("should not be equal", func() {
|
||||
dc1 := &types.DHCPServerConfig{
|
||||
V4: &types.V4ServerConfJSON{
|
||||
GatewayIP: net.IPv4(1, 2, 3, 3),
|
||||
LeaseDuration: 123,
|
||||
RangeStart: net.IPv4(1, 2, 3, 5),
|
||||
RangeEnd: net.IPv4(1, 2, 3, 6),
|
||||
SubnetMask: net.IPv4(255, 255, 255, 0),
|
||||
},
|
||||
}
|
||||
dc2 := &types.DHCPServerConfig{
|
||||
V4: &types.V4ServerConfJSON{
|
||||
GatewayIP: net.IPv4(1, 2, 3, 4),
|
||||
LeaseDuration: 123,
|
||||
RangeStart: net.IPv4(1, 2, 3, 5),
|
||||
RangeEnd: net.IPv4(1, 2, 3, 6),
|
||||
SubnetMask: net.IPv4(255, 255, 255, 0),
|
||||
},
|
||||
}
|
||||
Ω(dc1.Equals(dc2)).ShouldNot(BeTrue())
|
||||
})
|
||||
})
|
||||
Context("Clone", func() {
|
||||
It("clone should be equal", func() {
|
||||
dc1 := &types.DHCPServerConfig{
|
||||
V4: &types.V4ServerConfJSON{
|
||||
GatewayIP: net.IPv4(1, 2, 3, 4),
|
||||
LeaseDuration: 123,
|
||||
RangeStart: net.IPv4(1, 2, 3, 5),
|
||||
RangeEnd: net.IPv4(1, 2, 3, 6),
|
||||
SubnetMask: net.IPv4(255, 255, 255, 0),
|
||||
},
|
||||
}
|
||||
Ω(dc1.Clone().Equals(dc1)).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue