60 lines
1.1 KiB
Go
60 lines
1.1 KiB
Go
|
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
|
||
|
|
||
|
package resource
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
_ "encoding/json"
|
||
|
_ "fmt"
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
_ "gopkg.in/yaml.v3"
|
||
|
_ "io"
|
||
|
_ "log"
|
||
|
_ "net/http"
|
||
|
_ "net/http/httptest"
|
||
|
_ "net/url"
|
||
|
_ "os"
|
||
|
_ "path/filepath"
|
||
|
_ "strings"
|
||
|
_ "syscall"
|
||
|
"testing"
|
||
|
_ "time"
|
||
|
)
|
||
|
|
||
|
func TestNewNetworkRouteResource(t *testing.T) {
|
||
|
n := NewNetworkRoute()
|
||
|
assert.NotEqual(t, nil, n)
|
||
|
}
|
||
|
|
||
|
func TestNetworkRouteApplyResourceTransformation(t *testing.T) {
|
||
|
n := NewNetworkRoute()
|
||
|
assert.NotEqual(t, nil, n)
|
||
|
|
||
|
//e := f.Apply()
|
||
|
//assert.Equal(t, nil, e)
|
||
|
}
|
||
|
|
||
|
func TestReadNetworkRoute(t *testing.T) {
|
||
|
ctx := context.Background()
|
||
|
|
||
|
declarationAttributes := `
|
||
|
to: "192.168.0.0/24"
|
||
|
interface: "eth0"
|
||
|
gateway: "192.168.0.1"
|
||
|
metric: 0
|
||
|
routetype: "unicast"
|
||
|
scope: "link"
|
||
|
state: present
|
||
|
`
|
||
|
|
||
|
testRoute := NewNetworkRoute()
|
||
|
e := testRoute.LoadDecl(declarationAttributes)
|
||
|
assert.Equal(t, nil, e)
|
||
|
testRoute.Apply()
|
||
|
r, e := testRoute.Read(ctx)
|
||
|
|
||
|
assert.Nil(t, e)
|
||
|
assert.NotNil(t, r)
|
||
|
assert.Equal(t, NetworkRouteType("unicast"), testRoute.RouteType)
|
||
|
}
|