summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/option_bootfileurl_test.go
blob: ac45ef5167dec9fca89883a926c95185db93e535 (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
package dhcpv6

import (
	"bytes"
	"testing"

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

func TestOptBootFileURL(t *testing.T) {
	expected := "https://insomniac.slackware.it"
	opt, err := parseOptBootFileURL([]byte(expected))
	if err != nil {
		t.Fatal(err)
	}
	if string(opt) != expected {
		t.Fatalf("Invalid boot file URL. Expected %v, got %v", expected, opt)
	}
	require.Contains(t, opt.String(), "https://insomniac.slackware.it", "String() should contain the correct BootFileUrl output")
}

func TestOptBootFileURLToBytes(t *testing.T) {
	urlString := "https://insomniac.slackware.it"
	opt := OptBootFileURL(urlString)
	toBytes := opt.ToBytes()
	if !bytes.Equal(toBytes, []byte(urlString)) {
		t.Fatalf("Invalid ToBytes result. Expected %v, got %v", urlString, toBytes)
	}
}