2024-03-25 20:27:30 +00:00
|
|
|
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved
|
2024-07-22 22:03:22 +00:00
|
|
|
|
|
|
|
|
2024-03-25 20:27:30 +00:00
|
|
|
package resource
|
|
|
|
|
|
|
|
import (
|
2024-10-16 17:26:42 +00:00
|
|
|
_ "context"
|
|
|
|
_ "encoding/json"
|
|
|
|
_ "fmt"
|
2024-03-25 20:27:30 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
2024-10-16 17:26:42 +00:00
|
|
|
_ "gopkg.in/yaml.v3"
|
|
|
|
_ "io"
|
|
|
|
_ "log"
|
|
|
|
_ "net/http"
|
|
|
|
_ "net/http/httptest"
|
|
|
|
_ "net/url"
|
|
|
|
_ "os"
|
|
|
|
_ "strings"
|
2024-03-25 20:27:30 +00:00
|
|
|
"testing"
|
2024-07-22 22:03:22 +00:00
|
|
|
"decl/internal/command"
|
2024-10-16 17:26:42 +00:00
|
|
|
"decl/internal/folio"
|
2024-03-25 20:27:30 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestNewExecResource(t *testing.T) {
|
|
|
|
x := NewExec()
|
2024-04-05 17:22:17 +00:00
|
|
|
assert.NotNil(t, x)
|
2024-03-25 20:27:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestExecApplyResourceTransformation(t *testing.T) {
|
|
|
|
x := NewExec()
|
2024-04-05 17:22:17 +00:00
|
|
|
assert.NotNil(t, x)
|
2024-03-25 20:27:30 +00:00
|
|
|
|
|
|
|
//e := f.Apply()
|
|
|
|
//assert.Equal(t, nil, e)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestReadExec(t *testing.T) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestReadExecError(t *testing.T) {
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCreateExec(t *testing.T) {
|
2024-07-22 22:03:22 +00:00
|
|
|
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])
|
2024-03-25 20:27:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestExecSetURI(t *testing.T) {
|
2024-10-16 17:26:42 +00:00
|
|
|
var uri folio.URI = "exec://12345_key"
|
2024-03-25 20:31:06 +00:00
|
|
|
x := NewExec()
|
|
|
|
assert.NotNil(t, x)
|
2024-10-16 17:26:42 +00:00
|
|
|
e := x.SetParsedURI(uri.Parse())
|
2024-04-03 19:27:16 +00:00
|
|
|
assert.Nil(t, e)
|
2024-03-25 20:31:06 +00:00
|
|
|
assert.Equal(t, "exec", x.Type())
|
2024-09-19 08:05:29 +00:00
|
|
|
assert.Equal(t, "12345_key", x.Path)
|
2024-03-25 20:27:30 +00:00
|
|
|
}
|