31 lines
No EOL
760 B
Go
31 lines
No EOL
760 B
Go
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")
|
|
} |