concourse-dsa-resource/internal/resource/dsa/dsa_test.go
Jan Dittberner 182f21944b Use correct long description from DSA long RDF
- use date and DSA number as version identifier
- add tests for Check and Get calls
2023-01-22 13:18:57 +01:00

51 lines
872 B
Go

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)
}