summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/dhcpv4_test.go
diff options
context:
space:
mode:
authorAndrea Barberio <insomniac@slackware.it>2018-12-08 22:17:28 +0000
committerAndrea Barberio <insomniac@slackware.it>2018-12-08 22:17:28 +0000
commit08c8b272d33662a5448d4b789466a3de79050ed8 (patch)
tree19ba7036e1e57a3f8505a9eb2d7cacbcf9843889 /dhcpv4/dhcpv4_test.go
parent4dabb19b0ae8c2c0287807d4454eedee46d39a2d (diff)
Added netconf v4 tests and required modifiers
Diffstat (limited to 'dhcpv4/dhcpv4_test.go')
-rw-r--r--dhcpv4/dhcpv4_test.go21
1 files changed, 18 insertions, 3 deletions
diff --git a/dhcpv4/dhcpv4_test.go b/dhcpv4/dhcpv4_test.go
index 059ae0c..283e728 100644
--- a/dhcpv4/dhcpv4_test.go
+++ b/dhcpv4/dhcpv4_test.go
@@ -347,9 +347,7 @@ func TestGetOption(t *testing.T) {
func TestAddOption(t *testing.T) {
d, err := New()
- if err != nil {
- t.Fatal(err)
- }
+ require.NoError(t, err)
hostnameOpt := &OptionGeneric{OptionCode: OptionHostName, Data: []byte("darkstar")}
bootFileOpt1 := &OptionGeneric{OptionCode: OptionBootfileName, Data: []byte("boot.img")}
@@ -363,6 +361,23 @@ func TestAddOption(t *testing.T) {
require.Equal(t, options[3].Code(), OptionEnd)
}
+func TestUpdateOption(t *testing.T) {
+ d, err := New()
+ require.NoError(t, err)
+ require.Equal(t, 1, len(d.options))
+ require.Equal(t, OptionEnd, d.options[0].Code())
+ // test that it will add the option since it's missing
+ d.UpdateOption(&OptDomainName{DomainName: "slackware.it"})
+ require.Equal(t, 2, len(d.options))
+ require.Equal(t, OptionDomainName, d.options[0].Code())
+ require.Equal(t, OptionEnd, d.options[1].Code())
+ // test that it won't add another option of the same type
+ d.UpdateOption(&OptDomainName{DomainName: "slackware.it"})
+ require.Equal(t, 2, len(d.options))
+ require.Equal(t, OptionDomainName, d.options[0].Code())
+ require.Equal(t, OptionEnd, d.options[1].Code())
+}
+
func TestStrippedOptions(t *testing.T) {
// Normal set of options that terminate with OptionEnd.
d, err := New()