Improve coverage with more schema tests

This commit is contained in:
Brian Beck 2016-12-08 14:11:05 -08:00
parent 31fecabfda
commit 5b41af6e6a
24 changed files with 358 additions and 22 deletions

View file

@ -1,22 +1,22 @@
{
"statusCode": 200,
"headers": {
"date": "Wed, 07 Dec 2016 23:09:35 GMT",
"date": "Thu, 08 Dec 2016 22:10:36 GMT",
"content-type": "application/json; charset=UTF-8",
"transfer-encoding": "chunked",
"connection": "keep-alive",
"keep-alive": "timeout=15",
"vary": "Accept-Encoding",
"x-ratelimit-limit": "700",
"x-ratelimit-remaining": "361",
"x-ratelimit-reset": "1481152175",
"x-ratelimit-remaining": "547",
"x-ratelimit-reset": "1481235037",
"last-modified": "Wed, 09 Nov 2016 23:43:24 GMT",
"server": "Jetty(9.3.10.v20160621)",
"access-control-allow-origin": "*",
"content-encoding": "gzip"
},
"url": "http://musicbrainz.org:80/ws/2/recording?query=Burn%20the%20Witch&fmt=json",
"time": 744,
"time": 604,
"request": {
"method": "GET",
"headers": {

Binary file not shown.

View file

@ -0,0 +1,29 @@
{
"statusCode": 200,
"headers": {
"date": "Thu, 08 Dec 2016 22:10:38 GMT",
"content-type": "application/json; charset=UTF-8",
"transfer-encoding": "chunked",
"connection": "keep-alive",
"keep-alive": "timeout=15",
"vary": "Accept-Encoding",
"x-ratelimit-limit": "700",
"x-ratelimit-remaining": "679",
"x-ratelimit-reset": "1481235039",
"last-modified": "Thu, 08 Dec 2016 21:32:00 GMT",
"server": "Jetty(9.3.10.v20160621)",
"access-control-allow-origin": "*",
"content-encoding": "gzip"
},
"url": "http://musicbrainz.org:80/ws/2/label?limit=1&query=Apple%20Records&fmt=json",
"time": 1473,
"request": {
"method": "GET",
"headers": {
"User-Agent": "graphbrainz/3.1.0 ( https://github.com/exogen/graphbrainz )",
"host": "musicbrainz.org",
"accept-encoding": "gzip, deflate",
"accept": "application/json"
}
}
}

Binary file not shown.

View file

@ -1,22 +1,22 @@
{
"statusCode": 200,
"headers": {
"date": "Wed, 07 Dec 2016 23:09:34 GMT",
"date": "Thu, 08 Dec 2016 22:10:35 GMT",
"content-type": "application/json; charset=utf-8",
"transfer-encoding": "chunked",
"connection": "keep-alive",
"keep-alive": "timeout=15",
"vary": "Accept-Encoding",
"x-ratelimit-limit": "700",
"x-ratelimit-remaining": "596",
"x-ratelimit-reset": "1481152175",
"x-ratelimit-remaining": "250",
"x-ratelimit-reset": "1481235035",
"server": "Plack::Handler::Starlet",
"etag": "W/\"70e9c6b355083588be1b5abb2e76e291\"",
"etag": "W/\"39c7b86496389329f958f3d9d8599d32\"",
"access-control-allow-origin": "*",
"content-encoding": "gzip"
},
"url": "http://musicbrainz.org:80/ws/2/artist/c8da2e40-bd28-4d4e-813a-bd2f51958ba8?fmt=json",
"time": 361,
"time": 3316,
"request": {
"method": "GET",
"headers": {

Binary file not shown.

View file

@ -0,0 +1,29 @@
{
"statusCode": 200,
"headers": {
"date": "Thu, 08 Dec 2016 22:10:44 GMT",
"content-type": "application/json; charset=utf-8",
"transfer-encoding": "chunked",
"connection": "keep-alive",
"keep-alive": "timeout=15",
"vary": "Accept-Encoding",
"x-ratelimit-limit": "700",
"x-ratelimit-remaining": "553",
"x-ratelimit-reset": "1481235045",
"server": "Plack::Handler::Starlet",
"etag": "W/\"1bb5095802d059afef4624c8e955cac9\"",
"access-control-allow-origin": "*",
"content-encoding": "gzip"
},
"url": "http://musicbrainz.org:80/ws/2/artist/300c4c73-33ac-4255-9d57-4e32627f5e13?inc=artist-rels&fmt=json",
"time": 2141,
"request": {
"method": "GET",
"headers": {
"User-Agent": "graphbrainz/3.1.0 ( https://github.com/exogen/graphbrainz )",
"host": "musicbrainz.org",
"accept-encoding": "gzip, deflate",
"accept": "application/json"
}
}
}

Binary file not shown.

View file

@ -0,0 +1,29 @@
{
"statusCode": 200,
"headers": {
"date": "Thu, 08 Dec 2016 22:10:44 GMT",
"content-type": "application/json; charset=utf-8",
"transfer-encoding": "chunked",
"connection": "keep-alive",
"keep-alive": "timeout=15",
"vary": "Accept-Encoding",
"x-ratelimit-limit": "700",
"x-ratelimit-remaining": "552",
"x-ratelimit-reset": "1481235045",
"server": "Plack::Handler::Starlet",
"etag": "W/\"6ef3837bacadc37c2b7f98ef14494ffa\"",
"access-control-allow-origin": "*",
"content-encoding": "gzip"
},
"url": "http://musicbrainz.org:80/ws/2/artist/0d4ab0f9-bbda-4ab1-ae2c-f772ffcfbea9?inc=artist-rels&fmt=json",
"time": 2139,
"request": {
"method": "GET",
"headers": {
"User-Agent": "graphbrainz/3.1.0 ( https://github.com/exogen/graphbrainz )",
"host": "musicbrainz.org",
"accept-encoding": "gzip, deflate",
"accept": "application/json"
}
}
}

Binary file not shown.

View file

@ -0,0 +1,29 @@
{
"statusCode": 200,
"headers": {
"date": "Thu, 08 Dec 2016 22:10:38 GMT",
"content-type": "application/json; charset=utf-8",
"transfer-encoding": "chunked",
"connection": "keep-alive",
"keep-alive": "timeout=15",
"vary": "Accept-Encoding",
"x-ratelimit-limit": "700",
"x-ratelimit-remaining": "381",
"x-ratelimit-reset": "1481235039",
"server": "Plack::Handler::Starlet",
"etag": "W/\"39e8c37928b3a6031027cd8ab314a49d\"",
"access-control-allow-origin": "*",
"content-encoding": "gzip"
},
"url": "http://musicbrainz.org:80/ws/2/release?label=cf7fc5cf-e011-4ef4-b511-cd0188537910&limit=1&fmt=json",
"time": 525,
"request": {
"method": "GET",
"headers": {
"User-Agent": "graphbrainz/3.1.0 ( https://github.com/exogen/graphbrainz )",
"host": "musicbrainz.org",
"accept-encoding": "gzip, deflate",
"accept": "application/json"
}
}
}

Binary file not shown.

View file

@ -0,0 +1,29 @@
{
"statusCode": 200,
"headers": {
"date": "Thu, 08 Dec 2016 22:10:47 GMT",
"content-type": "application/json; charset=utf-8",
"transfer-encoding": "chunked",
"connection": "keep-alive",
"keep-alive": "timeout=15",
"vary": "Accept-Encoding",
"x-ratelimit-limit": "700",
"x-ratelimit-remaining": "297",
"x-ratelimit-reset": "1481235047",
"server": "Plack::Handler::Starlet",
"etag": "W/\"40e494f99de2f93d29eb00587cf919e8\"",
"access-control-allow-origin": "*",
"content-encoding": "gzip"
},
"url": "http://musicbrainz.org:80/ws/2/artist/ba550d0e-adac-4864-b88b-407cab5e76af?inc=artist-rels&fmt=json",
"time": 578,
"request": {
"method": "GET",
"headers": {
"User-Agent": "graphbrainz/3.1.0 ( https://github.com/exogen/graphbrainz )",
"host": "musicbrainz.org",
"accept-encoding": "gzip, deflate",
"accept": "application/json"
}
}
}

Binary file not shown.

View file

@ -1,22 +1,22 @@
{
"statusCode": 200,
"headers": {
"date": "Wed, 07 Dec 2016 23:09:35 GMT",
"date": "Thu, 08 Dec 2016 22:10:36 GMT",
"content-type": "application/json; charset=utf-8",
"transfer-encoding": "chunked",
"connection": "keep-alive",
"keep-alive": "timeout=15",
"vary": "Accept-Encoding",
"x-ratelimit-limit": "700",
"x-ratelimit-remaining": "154",
"x-ratelimit-reset": "1481152175",
"x-ratelimit-remaining": "396",
"x-ratelimit-reset": "1481235037",
"server": "Plack::Handler::Starlet",
"etag": "W/\"141f49e0130d012e9f5ffc328bc55045\"",
"etag": "W/\"94bf3bba877af6290e53de6524fcbdf3\"",
"access-control-allow-origin": "*",
"content-encoding": "gzip"
},
"url": "http://musicbrainz.org:80/ws/2/release-group?artist=c8da2e40-bd28-4d4e-813a-bd2f51958ba8&inc=artist-credits&fmt=json",
"time": 379,
"time": 490,
"request": {
"method": "GET",
"headers": {

Binary file not shown.

View file

@ -0,0 +1,29 @@
{
"statusCode": 200,
"headers": {
"date": "Thu, 08 Dec 2016 22:10:44 GMT",
"content-type": "application/json; charset=utf-8",
"transfer-encoding": "chunked",
"connection": "keep-alive",
"keep-alive": "timeout=15",
"vary": "Accept-Encoding",
"x-ratelimit-limit": "700",
"x-ratelimit-remaining": "551",
"x-ratelimit-reset": "1481235045",
"server": "Plack::Handler::Starlet",
"etag": "W/\"ff712330ac15db00e8bfb935e809bf95\"",
"access-control-allow-origin": "*",
"content-encoding": "gzip"
},
"url": "http://musicbrainz.org:80/ws/2/artist/49a51491-650e-44b3-8085-2f07ac2986dd?inc=artist-rels&fmt=json",
"time": 2134,
"request": {
"method": "GET",
"headers": {
"User-Agent": "graphbrainz/3.1.0 ( https://github.com/exogen/graphbrainz )",
"host": "musicbrainz.org",
"accept-encoding": "gzip, deflate",
"accept": "application/json"
}
}
}

Binary file not shown.

View file

@ -0,0 +1,29 @@
{
"statusCode": 200,
"headers": {
"date": "Thu, 08 Dec 2016 22:10:42 GMT",
"content-type": "application/json; charset=utf-8",
"transfer-encoding": "chunked",
"connection": "keep-alive",
"keep-alive": "timeout=15",
"vary": "Accept-Encoding",
"x-ratelimit-limit": "700",
"x-ratelimit-remaining": "574",
"x-ratelimit-reset": "1481235043",
"server": "Plack::Handler::Starlet",
"etag": "W/\"a60590c307227cfa6ee8fff91153f1bc\"",
"access-control-allow-origin": "*",
"content-encoding": "gzip"
},
"url": "http://musicbrainz.org:80/ws/2/artist?release=2ac3cbf2-f0d0-3678-af5f-b62dcb051bc0&inc=artist-rels&fmt=json",
"time": 1544,
"request": {
"method": "GET",
"headers": {
"User-Agent": "graphbrainz/3.1.0 ( https://github.com/exogen/graphbrainz )",
"host": "musicbrainz.org",
"accept-encoding": "gzip, deflate",
"accept": "application/json"
}
}
}

Binary file not shown.

View file

@ -0,0 +1,29 @@
{
"statusCode": 200,
"headers": {
"date": "Thu, 08 Dec 2016 22:10:47 GMT",
"content-type": "application/json; charset=utf-8",
"transfer-encoding": "chunked",
"connection": "keep-alive",
"keep-alive": "timeout=15",
"vary": "Accept-Encoding",
"x-ratelimit-limit": "700",
"x-ratelimit-remaining": "299",
"x-ratelimit-reset": "1481235047",
"server": "Plack::Handler::Starlet",
"etag": "W/\"fa1c3dc12994eab7fe0dcb44b627373c\"",
"access-control-allow-origin": "*",
"content-encoding": "gzip"
},
"url": "http://musicbrainz.org:80/ws/2/artist/4d5447d7-c61c-4120-ba1b-d7f471d385b9?inc=artist-rels&fmt=json",
"time": 538,
"request": {
"method": "GET",
"headers": {
"User-Agent": "graphbrainz/3.1.0 ( https://github.com/exogen/graphbrainz )",
"host": "musicbrainz.org",
"accept-encoding": "gzip, deflate",
"accept": "application/json"
}
}
}

Binary file not shown.

View file

@ -0,0 +1,29 @@
{
"statusCode": 200,
"headers": {
"date": "Thu, 08 Dec 2016 22:10:44 GMT",
"content-type": "application/json; charset=utf-8",
"transfer-encoding": "chunked",
"connection": "keep-alive",
"keep-alive": "timeout=15",
"vary": "Accept-Encoding",
"x-ratelimit-limit": "700",
"x-ratelimit-remaining": "550",
"x-ratelimit-reset": "1481235045",
"server": "Plack::Handler::Starlet",
"etag": "W/\"8816493f7872c79a0eabce9b71262302\"",
"access-control-allow-origin": "*",
"content-encoding": "gzip"
},
"url": "http://musicbrainz.org:80/ws/2/artist/42a8f507-8412-4611-854f-926571049fa0?inc=artist-rels&fmt=json",
"time": 2138,
"request": {
"method": "GET",
"headers": {
"User-Agent": "graphbrainz/3.1.0 ( https://github.com/exogen/graphbrainz )",
"host": "musicbrainz.org",
"accept-encoding": "gzip, deflate",
"accept": "application/json"
}
}
}

View file

@ -8,11 +8,9 @@ import createLoaders from '../src/loaders'
sepia.fixtureDir(path.join(__dirname, 'fixtures'))
test.beforeEach(t => {
const client = new MusicBrainz()
const loaders = createLoaders(client)
t.context = { client, loaders }
})
const client = new MusicBrainz()
const loaders = createLoaders(client)
const context = { client, loaders }
test('schema has a lookup query', t => {
const query = `
@ -26,7 +24,7 @@ test('schema has a lookup query', t => {
}
}
`
return graphql(schema, query, null, t.context).then(result => {
return graphql(schema, query, null, context).then(result => {
t.deepEqual(result, {
data: {
lookup: {
@ -58,7 +56,7 @@ test('schema has a search query', t => {
}
}
`
return graphql(schema, query, null, t.context).then(result => {
return graphql(schema, query, null, context).then(result => {
const { recordings } = result.data.search
t.true(recordings.totalCount > 0)
t.true(recordings.edges.length === 25)
@ -89,10 +87,87 @@ test('schema has a browse query', t => {
}
}
`
return graphql(schema, query, null, t.context).then(result => {
return graphql(schema, query, null, context).then(result => {
const { releaseGroups } = result.data.browse
t.true(releaseGroups.totalCount > 0)
t.true(releaseGroups.edges.length > 0)
releaseGroups.edges.forEach(edge => t.truthy(edge.node.title))
})
})
test('supports deeply nested queries', t => {
const query = `
query AppleRecordsMarriages {
search {
labels(query: "Apple Records", first: 1) {
edges {
node {
name
disambiguation
country
releases(first: 1) {
edges {
node {
title
date
artists {
edges {
node {
name
...bandMembers
}
}
}
}
}
}
}
}
}
}
}
fragment bandMembers on Artist {
relationships {
artists(direction: "backward", type: "member of band") {
edges {
node {
type
target {
... on Artist {
name
...marriages
}
}
}
}
}
}
}
fragment marriages on Artist {
relationships {
artists(type: "married") {
edges {
node {
type
direction
begin
end
target {
... on Artist {
name
}
}
}
}
}
}
}
`
return graphql(schema, query, null, context).then(result => {
const { labels } = result.data.search
t.true(labels.edges.length > 0)
t.is(labels.edges[0].node.releases.edges.length, 1)
})
})