jx/internal/resource/container_network_test.go
Matthew Rich 43a2274b7e
Some checks failed
Lint / golangci-lint (push) Failing after 9m50s
Declarative Tests / test (push) Failing after 10s
update container/iptables resources
2024-05-05 17:48:54 -07:00

48 lines
1006 B
Go

// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
package resource
import (
"context"
"decl/tests/mocks"
_ "encoding/json"
_ "fmt"
_ "github.com/docker/docker/api/types"
_ "github.com/docker/docker/api/types/container"
_ "github.com/docker/docker/api/types/network"
"github.com/stretchr/testify/assert"
_ "io"
_ "net/http"
_ "net/http/httptest"
_ "net/url"
_ "os"
_ "strings"
"testing"
)
func TestNewContainerNetworkResource(t *testing.T) {
c := NewContainerNetwork(&mocks.MockContainerClient{})
assert.NotNil(t, c)
}
func TestReadContainerNetwork(t *testing.T) {
ctx := context.Background()
decl := `
name: "testcontainernetwork"
state: present
`
m := &mocks.MockContainerClient{
}
n := NewContainerNetwork(m)
assert.NotNil(t, n)
e := n.LoadDecl(decl)
assert.Nil(t, e)
assert.Equal(t, "testcontainernetwork", n.Name)
resourceYaml, readContainerErr := n.Read(ctx)
assert.Equal(t, nil, readContainerErr)
assert.Greater(t, len(resourceYaml), 0)
}