mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
test: Add SPARQL endpoint integration test.
This commit is contained in:
parent
17d774fc18
commit
1055beea92
18
.travis.yml
18
.travis.yml
@ -1,10 +1,18 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "10"
|
||||
- "12"
|
||||
- "14"
|
||||
- "lts/*"
|
||||
- "node"
|
||||
- "10"
|
||||
- "12"
|
||||
- "14"
|
||||
- "lts/*"
|
||||
- "node"
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
before_install:
|
||||
# Set up SPARQL endpoint
|
||||
- docker pull tenforce/virtuoso
|
||||
- docker run -d -p 4000:8890 -e SPARQL_UPDATE=true tenforce/virtuoso
|
||||
|
||||
script:
|
||||
- npm run lint
|
||||
|
6
test/assets/person.ttl
Normal file
6
test/assets/person.ttl
Normal file
@ -0,0 +1,6 @@
|
||||
PREFIX : <https://ruben.verborgh.org/profile/#>
|
||||
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
|
||||
|
||||
:me a foaf:Person;
|
||||
foaf:name "Ruben Verborgh"@en;
|
||||
foaf:homepage <https://ruben.verborgh.org/>.
|
@ -31,10 +31,11 @@ import {
|
||||
export class DataAccessorBasedConfig implements ServerConfig {
|
||||
public store: ResourceStore;
|
||||
|
||||
public constructor(base: string, dataAccessor: DataAccessor) {
|
||||
public constructor(base: string, dataAccessor: DataAccessor, inType?: string) {
|
||||
this.store = getConvertingStore(
|
||||
getDataAccessorStore(base, dataAccessor),
|
||||
[ new QuadToRdfConverter(), new RdfToQuadConverter() ],
|
||||
inType,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -75,8 +75,13 @@ export const getInMemoryResourceStore = (base = BASE): DataAccessorBasedStore =>
|
||||
* @returns The converting store.
|
||||
*/
|
||||
export const getConvertingStore =
|
||||
(store: ResourceStore, converters: RepresentationConverter[]): RepresentationConvertingStore =>
|
||||
new RepresentationConvertingStore(store, { outConverter: new CompositeAsyncHandler(converters) });
|
||||
(store: ResourceStore, converters: RepresentationConverter[], inType?: string):
|
||||
RepresentationConvertingStore =>
|
||||
new RepresentationConvertingStore(store, {
|
||||
inConverter: new CompositeAsyncHandler(converters),
|
||||
outConverter: new CompositeAsyncHandler(converters),
|
||||
inType,
|
||||
});
|
||||
|
||||
/**
|
||||
* Gives a patching store based on initial store.
|
||||
|
28
test/integration/SparqlStorage.test.ts
Normal file
28
test/integration/SparqlStorage.test.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { SparqlDataAccessor } from '../../src/storage/accessors/SparqlDataAccessor';
|
||||
import { UrlContainerManager } from '../../src/storage/UrlContainerManager';
|
||||
import { INTERNAL_QUADS } from '../../src/util/ContentTypes';
|
||||
import { MetadataController } from '../../src/util/MetadataController';
|
||||
import { DataAccessorBasedConfig } from '../configs/DataAccessorBasedConfig';
|
||||
import { BASE } from '../configs/Util';
|
||||
import { FileTestHelper } from '../util/TestHelpers';
|
||||
|
||||
describe('A server with a SPARQL endpoint as storage', (): void => {
|
||||
describe('without acl', (): void => {
|
||||
const config = new DataAccessorBasedConfig(BASE,
|
||||
new SparqlDataAccessor('http://localhost:4000/sparql',
|
||||
BASE,
|
||||
new UrlContainerManager(BASE),
|
||||
new MetadataController()),
|
||||
INTERNAL_QUADS);
|
||||
const handler = config.getHttpHandler();
|
||||
const fileHelper = new FileTestHelper(handler, new URL(BASE));
|
||||
|
||||
it('can add a Turtle file to the store.', async():
|
||||
Promise<void> => {
|
||||
// POST
|
||||
const response = await fileHelper.createFile('../assets/person.ttl', 'person', 'text/turtle');
|
||||
const id = response._getHeaders().location;
|
||||
expect(id).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user