This repository has been archived by the owner on Nov 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathldget_test.go
64 lines (56 loc) · 2.41 KB
/
ldget_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package main
import (
"fmt"
"os"
"testing"
"github.com/kami-zh/go-capturer"
srv "github.com/ontola/ldget/testing"
)
var subj = "https://app.argu.co/argu/u/joep"
var subjOut = "<https://app.argu.co/argu/u/joep>\n"
var pred = "http://schema.org/description"
var predOut = "<http://schema.org/description>\n"
var ntriple = "<https://app.argu.co/argu/u/joep> <http://schema.org/description> \"Liefhebber van discussiëren, ontwerpen en problemen oplossen. Een van de mede-oprichters van Argu.\" .\n"
var descriptionOut = "\"Liefhebber van discussiëren, ontwerpen en problemen oplossen. Een van de mede-oprichters van Argu.\"\n"
var predObjOut = "<http://schema.org/description> \"Liefhebber van discussiëren, ontwerpen en problemen oplossen. Een van de mede-oprichters van Argu.\"\n"
// Will probably return ldget
var appname = os.Args[0:1][0]
var objectTests = []struct {
in []string
out string
}{
// Object ttl
{[]string{appname, "objects", subj, pred, "--resource=http://localhost:8080/joep.ttl"}, descriptionOut},
// Object rdf, shortname
{[]string{appname, "o", subj, pred, "--resource=http://localhost:8080/joep.rdf"}, descriptionOut},
// Object nt
{[]string{appname, "objects", subj, pred, "--resource=http://localhost:8080/joep.nt"}, descriptionOut},
// Object prefix
{[]string{appname, "o", subj, "schema:description", "--resource=http://localhost:8080/joep.rdf"}, descriptionOut},
// TODO: add JSON-LD support
// {[]string{appname, "objects", subj, pred, "--resource=http://localhost:8080/joep.jsonld"}, description},
// Triples
{[]string{appname, "triples", subj, pred, "--resource=http://localhost:8080/joep.ttl"}, ntriple},
{[]string{appname, "t", subj, pred, "--resource=http://localhost:8080/joep.ttl"}, ntriple},
// Subjects
{[]string{appname, "subjects", subj, pred, "--resource=http://localhost:8080/joep.ttl"}, subjOut},
// Predicates
{[]string{appname, "predicates", subj, pred, "--resource=http://localhost:8080/joep.ttl"}, predOut},
// PredicateObjects
{[]string{appname, "po", subj, pred, "--resource=http://localhost:8080/joep.ttl"}, predObjOut},
}
func TestObjectParser(t *testing.T) {
go srv.Testserver()
// Execute every single test string from objectTests
for _, tt := range objectTests {
fmt.Print(tt.in[0:])
out := capturer.CaptureStdout(func() {
run(tt.in)
})
if tt.out != out {
t.Error(fmt.Sprintf("Expected: \n%vGot:\n%v", tt.out, out))
} else {
fmt.Print(" -- PASS\n")
}
}
}