jx/internal/resource/network_route_test.go

61 lines
1.1 KiB
Go
Raw Permalink Normal View History

2024-04-02 20:35:40 +00:00
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
package resource
import (
"context"
2024-05-24 05:11:51 +00:00
_ "encoding/json"
_ "fmt"
2024-04-02 20:35:40 +00:00
"github.com/stretchr/testify/assert"
2024-05-24 05:11:51 +00:00
_ "gopkg.in/yaml.v3"
_ "io"
_ "log"
_ "net/http"
_ "net/http/httptest"
_ "net/url"
_ "os"
_ "path/filepath"
_ "strings"
_ "syscall"
2024-04-02 20:35:40 +00:00
"testing"
2024-05-24 05:11:51 +00:00
_ "time"
2024-04-02 20:35:40 +00:00
)
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"
gateway: "192.168.0.1"
metric: 0
routetype: "unicast"
scope: "link"
state: present
`
testRoute := NewNetworkRoute()
e := testRoute.LoadDecl(declarationAttributes)
2024-05-24 05:11:51 +00:00
assert.Nil(t, e)
2024-04-03 19:27:16 +00:00
testRouteErr := testRoute.Apply()
assert.Nil(t, testRouteErr)
2024-04-02 20:35:40 +00:00
r, e := testRoute.Read(ctx)
2024-05-24 05:11:51 +00:00
assert.Equal(t, "", ExitError(e))
2024-04-02 20:35:40 +00:00
assert.NotNil(t, r)
assert.Equal(t, NetworkRouteType("unicast"), testRoute.RouteType)
}