Skip to content

Commit

Permalink
all: imp tests
Browse files Browse the repository at this point in the history
  • Loading branch information
schzhn committed Sep 24, 2024
1 parent 80f7e98 commit 0a001ff
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions internal/client/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,28 +420,12 @@ func TestClientsDHCP(t *testing.T) {
}

func TestClientsAddExisting(t *testing.T) {
// First, init a DHCP server with a single static lease.
config := &dhcpd.ServerConfig{
Enabled: true,
DataDir: t.TempDir(),
Conf4: dhcpd.V4ServerConf{
Enabled: true,
GatewayIP: netip.MustParseAddr("1.2.3.1"),
SubnetMask: netip.MustParseAddr("255.255.255.0"),
RangeStart: netip.MustParseAddr("1.2.3.2"),
RangeEnd: netip.MustParseAddr("1.2.3.10"),
},
}

dhcpServer, err := dhcpd.Create(config)
require.NoError(t, err)

storage, err := client.NewStorage(&client.StorageConfig{
DHCP: dhcpServer,
})
require.NoError(t, err)

t.Run("simple", func(t *testing.T) {
storage, err := client.NewStorage(&client.StorageConfig{
DHCP: client.EmptyDHCP{},
})
require.NoError(t, err)

ip := netip.MustParseAddr("1.1.1.1")

// Add a client.
Expand All @@ -467,6 +451,27 @@ func TestClientsAddExisting(t *testing.T) {
t.Skip("skipping dhcp test on windows")
}

// First, init a DHCP server with a single static lease.
config := &dhcpd.ServerConfig{
Enabled: true,
DataDir: t.TempDir(),
Conf4: dhcpd.V4ServerConf{
Enabled: true,
GatewayIP: netip.MustParseAddr("1.2.3.1"),
SubnetMask: netip.MustParseAddr("255.255.255.0"),
RangeStart: netip.MustParseAddr("1.2.3.2"),
RangeEnd: netip.MustParseAddr("1.2.3.10"),
},
}

dhcpServer, err := dhcpd.Create(config)
require.NoError(t, err)

storage, err := client.NewStorage(&client.StorageConfig{
DHCP: dhcpServer,
})
require.NoError(t, err)

ip := netip.MustParseAddr("1.2.3.4")

err = dhcpServer.AddStaticLease(&dhcpsvc.Lease{
Expand Down

0 comments on commit 0a001ff

Please sign in to comment.