66 lines
1.1 KiB
Go
66 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"
|
||
|
_ "strings"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestNewPackageResource(t *testing.T) {
|
||
|
p := NewPackage()
|
||
|
assert.NotNil(t, p)
|
||
|
}
|
||
|
|
||
|
func TestPackageApplyResourceTransformation(t *testing.T) {
|
||
|
p := NewPackage()
|
||
|
assert.NotNil(t, p)
|
||
|
|
||
|
//e := f.Apply()
|
||
|
//assert.Equal(t, nil, e)
|
||
|
}
|
||
|
|
||
|
func TestReadPackage(t *testing.T) {
|
||
|
decl:=`
|
||
|
name: vim
|
||
|
version: latest
|
||
|
type: apk
|
||
|
`
|
||
|
|
||
|
p := NewPackage()
|
||
|
assert.NotNil(t, p)
|
||
|
|
||
|
loadErr := p.LoadDecl(decl)
|
||
|
assert.Nil(t, loadErr)
|
||
|
|
||
|
yaml, readErr := p.Read(context.Background())
|
||
|
assert.Nil(t, readErr)
|
||
|
assert.Greater(t, len(yaml), 0)
|
||
|
}
|
||
|
|
||
|
func TestReadPackageError(t *testing.T) {
|
||
|
}
|
||
|
|
||
|
func TestCreatePackage(t *testing.T) {
|
||
|
}
|
||
|
|
||
|
func TestPackageSetURI(t *testing.T) {
|
||
|
p := NewPackage()
|
||
|
assert.NotNil(t, p)
|
||
|
e := p.SetURI("package://" + "12345_key")
|
||
|
assert.Nil(t, e)
|
||
|
assert.Equal(t, "package", p.Type())
|
||
|
assert.Equal(t, "12345_key", p.Name)
|
||
|
}
|