Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

GitHub testing with virtuoso service #16

Merged
merged 13 commits into from
Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
runs-on: ubuntu-latest
env:
CI: true
VIRTUOSO_INTEGRATION_TESTS: true
strategy:
fail-fast: false
matrix:
Expand All @@ -26,6 +27,15 @@ jobs:
- 3.0
- ruby-head # Eventualy
- jruby
services:
virtuoso:
image: tenforce/virtuoso
env:
DBA_PASSWORD: tester
SPARQL_UPDATE: true
ports:
- 8890:8890
- 1111:1111
steps:
- name: Clone repository
uses: actions/checkout@v2
Expand All @@ -35,6 +45,10 @@ jobs:
ruby-version: ${{ matrix.ruby }}
- name: Install dependencies
run: bundle install --jobs 4 --retry 3
- name: Wait to give Virtuoso a little extra time
uses: juliangruber/sleep-action@v1
with:
time: '3s'
- name: Run tests
run: bundle exec rspec spec

56 changes: 56 additions & 0 deletions spec/integration_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# frozen_string_literal: true

$LOAD_PATH.unshift '.'
require_relative 'spec_helper'
require 'rdf/spec/repository'

# these tests rely on a Virtuoso service being available, at port 8890
# the easiest way to do this is with docker ( https://docs.docker.com/get-docker/ ), running the following:
# docker run -p 8890:8890 -p 1111:1111 -e DBA_PASSWORD=tester -e SPARQL_UPDATE=true --name virtuoso-testing -d tenforce/virtuoso
# when finished you can stop with
# docker stop virtuoso-testing
#
# to avoid the tests being skipped, you will need to set the environment variable VIRTUOSO_INTEGRATION_TESTS, e.g.
# VIRTUOSO_INTEGRATION_TESTS=true bundle exec rspec spec

skip = ENV['VIRTUOSO_INTEGRATION_TESTS'] ? false : 'Skipping Integration tests against a running repository, see spec/integration_spec.rb'

describe RDF::Virtuoso::Repository, skip: skip do
context('when interacting with a virtuoso repository service') do
subject(:repository) do
described_class.new(uri,
update_uri: update_uri,
username: username,
password: password,
auth_method: 'digest')
end

let(:uri) { 'http://localhost:8890/sparql' }
let(:update_uri) { 'http://localhost:8890/sparql-auth' }
let(:password) { 'tester' }
let(:username) { 'dba' }
let(:graph) { 'http://example.org/' }

it 'is able to select' do
# check a single triple result which is unlikely to change
query = RDF::Virtuoso::Query.select.where([RDF::URI('http://localhost:8890/sparql'),
RDF::URI('http://www.w3.org/ns/sparql-service-description#endpoint'), :o])

expect(repository.select(query).last.o).to eql RDF::URI('http://localhost:8890/sparql')
end

it 'is able to insert' do
query = RDF::Virtuoso::Query.insert([RDF::URI('subject:person'), RDF::URI('http://purl.org/dc/terms/title'),
'The title']).graph(graph)
expect(repository.insert(query)).to eql 'Insert into <http://example.org/>, 1 (or less) triples -- done'

# #clean up
query = RDF::Virtuoso::Query.delete([RDF::URI('subject:person'), :p,
:o]).where([RDF::URI('subject:person'), :p, :o]).graph(graph)
repository.delete(query)
end

# commented out until conformance issues are resolved, otherwise there are many errors
# it_behaves_like "an RDF::Repository"
end
end