summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/option_bootfile_name_test.go
blob: 38a200d3d958805146871df7febbb43b93d70f51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package dhcpv4

import (
	"testing"

	"github.com/stretchr/testify/require"
)

func TestOptBootfileNameCode(t *testing.T) {
	opt := OptBootfileName{}
	require.Equal(t, OptionBootfileName, opt.Code())
}

func TestOptBootfileNameToBytes(t *testing.T) {
	opt := OptBootfileName{
		BootfileName: "linuxboot",
	}
	data := opt.ToBytes()
	expected := []byte{
		'l', 'i', 'n', 'u', 'x', 'b', 'o', 'o', 't',
	}
	require.Equal(t, expected, data)
}

func TestParseOptBootfileName(t *testing.T) {
	expected := []byte{
		'l', 'i', 'n', 'u', 'x', 'b', 'o', 'o', 't',
	}
	opt, err := ParseOptBootfileName(expected)
	require.NoError(t, err)
	require.Equal(t, "linuxboot", opt.BootfileName)
}

func TestOptBootfileNameString(t *testing.T) {
	o := OptBootfileName{BootfileName: "testy test"}
	require.Equal(t, "Bootfile Name -> testy test", o.String())
}