jx/internal/resource/exec_test.go
Matthew Rich bcf4e768ff
Some checks are pending
Lint / golangci-lint (push) Waiting to run
Declarative Tests / test (push) Waiting to run
Declarative Tests / build-fedora (push) Waiting to run
Declarative Tests / build-ubuntu-focal (push) Waiting to run
Fix an issue with the package resource where a missing package would cause a fatal error
WIP: add support container image build using local filesytem contexts or contextes generated from resource definitions
WIP: added support for the create command in the exec resource
Fix a type matching error in `types` package use of generics
2024-07-22 15:03:22 -07:00

65 lines
1.2 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"
_ "strings"
"testing"
"decl/internal/command"
)
func TestNewExecResource(t *testing.T) {
x := NewExec()
assert.NotNil(t, x)
}
func TestExecApplyResourceTransformation(t *testing.T) {
x := NewExec()
assert.NotNil(t, x)
//e := f.Apply()
//assert.Equal(t, nil, e)
}
func TestReadExec(t *testing.T) {
}
func TestReadExecError(t *testing.T) {
}
func TestCreateExec(t *testing.T) {
x := NewExec()
decl := `
create:
path: go
args:
- install
- golang.org/x/vuln/cmd/govulncheck@latest
`
assert.Nil(t, x.LoadDecl(decl))
assert.Equal(t, "go", x.CreateTemplate.Path)
assert.Equal(t, command.CommandArg("golang.org/x/vuln/cmd/govulncheck@latest"), x.CreateTemplate.Args[1])
}
func TestExecSetURI(t *testing.T) {
x := NewExec()
assert.NotNil(t, x)
e := x.SetURI("exec://" + "12345_key")
assert.Nil(t, e)
assert.Equal(t, "exec", x.Type())
assert.Equal(t, "12345_key", x.Id)
}