jx/internal/resource/network_route_test.go
Matthew Rich 0888ae2045
Some checks failed
Lint / golangci-lint (push) Failing after 9m55s
Declarative Tests / test (push) Failing after 5s
add container-image resource
2024-05-23 22:11:51 -07:00

61 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"
gateway: "192.168.0.1"
metric: 0
routetype: "unicast"
scope: "link"
state: present
`
testRoute := NewNetworkRoute()
e := testRoute.LoadDecl(declarationAttributes)
assert.Nil(t, e)
testRouteErr := testRoute.Apply()
assert.Nil(t, testRouteErr)
r, e := testRoute.Read(ctx)
assert.Equal(t, "", ExitError(e))
assert.NotNil(t, r)
assert.Equal(t, NetworkRouteType("unicast"), testRoute.RouteType)
}