Use correct long description from DSA long RDF

- use date and DSA number as version identifier
- add tests for Check and Get calls
This commit is contained in:
Jan Dittberner 2023-01-22 13:18:57 +01:00
parent 12b2d36004
commit 182f21944b
5 changed files with 98 additions and 11 deletions

View file

@ -0,0 +1,51 @@
package dsa
import (
"bytes"
"fmt"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestResource_Check(t *testing.T) {
input := strings.NewReader("{}")
output := &bytes.Buffer{}
resource := NewResource(input, output)
err := resource.Check()
assert.NoError(t, err)
result := output.String()
assert.NotEmpty(t, result)
}
func TestResource_Get(t *testing.T) {
rdf, err := getRdfData(false)
item := rdf.Items[0]
parts := strings.SplitN(item.Title, " ", 2)
require.NoError(t, err)
input := strings.NewReader(fmt.Sprintf(
`{"source":{},"params":{},"version":{"date":"%s","dsa":"%s"}}`, item.Date, parts[0],
))
output := &bytes.Buffer{}
resource := NewResource(input, output)
err = resource.Get("/tmp")
assert.NoError(t, err)
result := output.String()
assert.NotEmpty(t, result)
}