Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix broken graphql after /reload #73

Merged
merged 2 commits into from
Apr 14, 2020
Merged
Changes from 1 commit
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
Next Next commit
add test to catch broken reload
  • Loading branch information
jmelis committed Apr 14, 2020
commit b9b59d6e78ee6a26bc2fe09174190b71e9037a6a
2 changes: 1 addition & 1 deletion test/schemas/cluster.test.ts
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ describe('clusters', async() => {

it('serves a basic graphql query', async() => {
const resp = await chai.request(srv).get('/graphql').query(
{ query: '{ clusters: clusters_v1 { name } }' }
{ query: '{ clusters: clusters_v1 { name } }' },
);
resp.should.have.status(200);
return resp.body.data.clusters[0].name.should.equal('example cluster');
2 changes: 1 addition & 1 deletion test/server.data.json
Original file line number Diff line number Diff line change
@@ -1230,4 +1230,4 @@
"sha256sum": "ff"
}
}
}
}
32 changes: 31 additions & 1 deletion test/server.test.ts
Original file line number Diff line number Diff line change
@@ -11,6 +11,9 @@ chai.use(chaiHttp);
import * as server from '../src/server';
import * as db from '../src/db';

process.env.LOAD_METHOD = 'fs';
process.env.DATAFILES_FILE = 'test/server.data.json';

const should = chai.should();
const expect = chai.expect;

@@ -24,7 +27,7 @@ describe('server', async() => {
// Setup and teardown the GraphQL HTTP server.
let srv: http.Server;
before(async() => {
const app = await server.appFromBundle(db.bundleFromDisk('test/server.data.json'));
const app = await server.appFromBundle(db.bundleFromEnvironment());
srv = app.listen({ port: 4000 });
});
after(async() => await util.promisify(srv.close));
@@ -78,4 +81,31 @@ describe('server', async() => {
responseIsNotAnError(response);
return response.body.data.resources[0].content.should.equal('test resource');
});

it('can retrieve a field from an interface', async() => {
const query = `{
roles: roles_v1(path: "/role-A.yml") {
permissions {
service
... on PermissionGithubOrgTeam_v1 {
org
}
}
}
}
`;

const response1 = await chai.request(srv).get('/graphql').query({ query });
responseIsNotAnError(response1);
response1.body.data.roles[0].permissions[0].org.should.equal('org-A');

// check that it continues to work after a reload
await chai.request(srv).post('/reload');

const response2 = await chai.request(srv).get('/graphql').query({ query });
responseIsNotAnError(response2);

const perm = response2.body.data.roles[0].permissions[0];
expect(perm.org).to.equal('org-A');
});
});