a73x

internal/agent/run/wire_linux_test.go

Ref:   Size: 808 B   History

//go:build linux

package run

import (
	"testing"

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

// TestProposeGuestCIDRIsTheFlagOrNoOpinion pins what a Linux host tells the
// fleet at enrollment about the subnet its guests will sit on. Silence is an
// answer here — nil takes the control plane's suggestion, which is what a host
// started without --bridge-cidr wants — and it is only ever this platform's to
// give, because only a host that CREATES the guest network may name it.
func TestProposeGuestCIDRIsTheFlagOrNoOpinion(t *testing.T) {
	assert.Nil(t, proposeGuestCIDR(Config{}),
		"no flag is no opinion, not a fabricated subnet")

	got := proposeGuestCIDR(Config{BridgeCIDR: "10.30.0.0/24"})
	require.NotNil(t, got)
	assert.Equal(t, "10.30.0.0/24", *got)
}