Web::Solid::Test::Basic - Basic Solid Tests
use Test::FITesque::RDF; my $suite = Test::FITesque::RDF->new(source => $file, base_uri => $ENV{SOLID_REMOTE_BASE})->suite; $suite->run_tests; done_testing;
See tests/basic.t for a full example.
tests/basic.t
The basic idea with these tests is to simplify reuse and formulation of fixture tables using the Resource Description Framework (RDF). It is in a very early stage, but there are running tests in this module.
This system is built on Test::FITesque::RDF, which adds RDF fixture tables to Test::FITesque.
Then, the idea is that modules such as this will provide a reusable implementation of certain tests, and that they can be adapted to concrete test scenarios by either passing parameters from the RDF tables (for both input variables and expected outcomes), or using environment variables.
To run the actual tests, test scripts will be made, but they should be terse as their only mission is to initialize the test framework, see the synopsis for an example of such a script. The script can then be invoked by e.g. CI systems or used in development.
The RDF fixture tables and the small wrapper scripts can exist independently of the module, and modules can be installed easily so that they can be reused. Nevertheless, it is also natural to package these together, like it has been done in this package.
Each module like this one will need to document the tests it implements, consider the below an example of how this should be done.
This package provides tests/basic.t which runs tests over the fixture table in tests/data/basic.ttl. The test script requires the environment variable SOLID_REMOTE_BASE to be set to the base URL that any relative URLs in the fixture tables will be resolved against. Thus, the fixture tables themselves are independent of the host that will run them.
tests/data/basic.ttl
SOLID_REMOTE_BASE
To run the test script in the clone of this package, invoke it like this:
SOLID_REMOTE_BASE="https://kjetiltest4.dev.inrupt.net/" prove -l tests/basic.t
http_read_unauthenticated
Some basic tests for HTTP reads.
url
The URL to request.
None
http_put_readback_unauthenticated
First writes some content with a PUT request, then reads it back with a GET and checks RDF validity.
http_write_with_bearer
Test for successful HTTP PUT authenticated with a Bearer token
Set SOLID_BEARER_TOKEN to the bearer token to be used in the authorization header.
SOLID_BEARER_TOKEN
http_methods_with_bearer
Tests for whether a certain HTTP request, authenticated with a Bearer token, returns a certain status code.
method
The HTTP method to use in the request.
body
The body of the request (optional).
code
The expected status code to tests for.
The parameters above are in the RDF formulated as actual full URIs, but where the local part is used here and resolved by the Test::FITesque::RDF framework, see its documentation for details.
The namespaces used in the current fixture tables are examples, and will be changed before an 1.0 release of the system.
Please report any bugs to https://github.com/kjetilk/p5-web-solid-test-basic/issues.
Kjetil Kjernsmo <kjetilk@cpan.org>.
This software is Copyright (c) 2019 by Inrupt Inc.
This is free software, licensed under:
The MIT (X11) License
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
To install Web::Solid::Test::Basic, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Web::Solid::Test::Basic
CPAN shell
perl -MCPAN -e shell install Web::Solid::Test::Basic
For more information on module installation, please visit the detailed CPAN module installation guide.