keksvpn/pkg/wgfunc/device_test.go

31 lines
760 B
Go
Raw Normal View History

2022-02-27 04:08:06 +00:00
package wgfunc
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestCreateAndDeleteDevice(t *testing.T) {
serverConfig := WireGuardConfig{
Name: "wgUnit",
}
server, err := NewWireGuard(serverConfig)
err = server.createNetworkDevice()
if err != nil {
assert.Nil(t, err, "shouldn't return error creating the network Device: %s", err)
}
foundDevice := checkForNetworkDevice("wgUnit", t)
assert.Truef(t, foundDevice, "should fount device with name wgUnit")
err = server.removeNetworkDevice()
if err != nil {
assert.Nil(t, err, "shouldn't return an error doing remove the network device again")
}
foundDevice = checkForNetworkDevice("wgUnit", t)
assert.Falsef(t, foundDevice, "should not fount device with name wgUnit")
}