frictionlessdata / datapackage-js

A JavaScript library for working with Data Package.
http://frictionlessdata.io/
MIT License
43 stars 15 forks source link

#41 table relative paths #48

Closed dumyan closed 7 years ago

dumyan commented 7 years ago

Resolves #41 by adding basePath for remote datapackages and after that using url.resolve in Resources class to point to the relative resource.

roll commented 7 years ago

@dumyan One other thing - I suppose we need much more tests for path resolutions. Could you write a few additional tests (for resource and datapackage if needed) with comprehensive list of combinations (basePath/path) to cover all edge cases? It could look like this for example:

it('resource source/type correctly works with base path', async () => {
  const paths = [
    {base: 'folder1', path: 'data/data.csv', source: 'folder1/data/data.csv', type: 'local'},
    // ... like 10 more)
  ]
  paths.forEach({base, path, source, type} => {
    const resource = new Resource({path}, base)
    assert(resource.source === source)
    assert(resource.type === type)
  })
})

it('resource source/type correctly works without base path', async () => {

The same technique could be used for other tests to ensure Resource.source/type works correctly on all possible input data.