|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +$LOAD_PATH.unshift '.' |
| 4 | +require_relative 'spec_helper' |
| 5 | +require 'rdf/spec/repository' |
| 6 | + |
| 7 | +# these tests rely on a Virtuoso service being available, at port 8890 |
| 8 | +# the easiest way to do this is with docker ( https://docs.docker.com/get-docker/ ), running the following: |
| 9 | +# docker run -p 8890:8890 -p 1111:1111 -e DBA_PASSWORD=tester -e SPARQL_UPDATE=true --name virtuoso-testing -d tenforce/virtuoso |
| 10 | +# when finished you can stop with |
| 11 | +# docker stop virtuoso-testing |
| 12 | +# |
| 13 | +# to avoid the tests being skipped, you will need to set the environment variable VIRTUOSO_INTEGRATION_TESTS, e.g. |
| 14 | +# VIRTUOSO_INTEGRATION_TESTS=true bundle exec rspec spec |
| 15 | + |
| 16 | +skip = ENV['VIRTUOSO_INTEGRATION_TESTS'] ? false : 'Skipping Integration tests against a running repository, see spec/integration_spec.rb' |
| 17 | + |
| 18 | +describe RDF::Virtuoso::Repository, skip: skip do |
| 19 | + context('when interacting with a virtuoso repository service') do |
| 20 | + subject(:repository) do |
| 21 | + described_class.new(uri, |
| 22 | + update_uri: update_uri, |
| 23 | + username: username, |
| 24 | + password: password, |
| 25 | + auth_method: 'digest') |
| 26 | + end |
| 27 | + |
| 28 | + let(:uri) { 'http://localhost:8890/sparql' } |
| 29 | + let(:update_uri) { 'http://localhost:8890/sparql-auth' } |
| 30 | + let(:password) { 'tester' } |
| 31 | + let(:username) { 'dba' } |
| 32 | + let(:graph) { 'http://example.org/' } |
| 33 | + |
| 34 | + it 'is able to select' do |
| 35 | + # check a single triple result which is unlikely to change |
| 36 | + query = RDF::Virtuoso::Query.select.where([RDF::URI('http://localhost:8890/sparql'), |
| 37 | + RDF::URI('http://www.w3.org/ns/sparql-service-description#endpoint'), :o]) |
| 38 | + |
| 39 | + expect(repository.select(query).last.o).to eql RDF::URI('http://localhost:8890/sparql') |
| 40 | + end |
| 41 | + |
| 42 | + it 'is able to insert' do |
| 43 | + query = RDF::Virtuoso::Query.insert([RDF::URI('subject:person'), RDF::URI('http://purl.org/dc/terms/title'), |
| 44 | + 'The title']).graph(graph) |
| 45 | + expect(repository.insert(query)).to eql 'Insert into <http://example.org/>, 1 (or less) triples -- done' |
| 46 | + |
| 47 | + # #clean up |
| 48 | + query = RDF::Virtuoso::Query.delete([RDF::URI('subject:person'), :p, |
| 49 | + :o]).where([RDF::URI('subject:person'), :p, :o]).graph(graph) |
| 50 | + repository.delete(query) |
| 51 | + end |
| 52 | + |
| 53 | + # commented out until conformance issues are resolved, otherwise there are many errors |
| 54 | + # it_behaves_like "an RDF::Repository" |
| 55 | + end |
| 56 | +end |
0 commit comments