Skip to content

Commit

Permalink
modified some a few endpoints to pass test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
amyfromandi committed Oct 23, 2024
1 parent 31323f7 commit 1211853
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 7 deletions.
40 changes: 38 additions & 2 deletions api-tests/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,45 @@ var request = require("supertest");
import * as fs from 'fs';
import * as path from 'path';

const testFiles = [

'units.ts'
const testFiles = [
'carto_small.ts',
'columns.ts'
'defs.ts',
'defs_columns.ts',
/*'defs_econs.ts',
'defs_environments.ts',
'defs_groups.ts',
'defs_intervals.ts',
'defs_lithologies.ts',
'defs_lithology_attributes.ts',
'defs_measurements.ts',
'defs_minerals.ts',
'defs_plates.ts',
'defs_projects.ts',
'defs_refs.ts',
'defs_sources.ts',
'defs_strat_name_concepts.ts',
'defs_strat_names.ts',
'defs_structures.ts',
'defs_timescales.ts',
'fossils.ts',
'geologic_units_burwell.ts',
'geologic_units_gmna.ts',
'geologic_units_gmus.ts',
'index.ts',
'mancos_test_cases.ts',
'mobile_fossil_collections.ts',
'mobile_macro_summary.ts',
'mobile_map_query.ts',
'mobile_point.ts',
'mobile_point_details.ts',
'paleogeography.ts',
'root.ts',
'sections.ts',
'stats.ts',
'tiles.ts',
'units.ts'*/
];
/*
'carto_small.ts',
Expand Down
1 change: 1 addition & 0 deletions api-tests/v2Tests/columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ request(settings.host)


it("should accept a project_id", function (done) {
this.timeout(7000);
request(settings.host)
.get("/columns?project_id=4")
.expect(validators.aSuccessfulRequest)
Expand Down
11 changes: 9 additions & 2 deletions v2/test/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,12 @@ module.exports = {
},

json: function (res) {
if (!res.body.success && !res.body.error) {
throw new Error("Request did not return valid JSON");
if (!res.body || (!res.body.success && !res.body.error)) {
throw new Error("Request did not return valid JSON or unexpected structure");
}
},


csv: function (res) {
if (res.body.length < 10) {
throw new Error("No CSV output recieved");
Expand All @@ -123,8 +124,14 @@ module.exports = {
},

atLeastOneResult: function (res) {
if (!res.body.success || !Array.isArray(res.body.success.data)) {
console.error("Response body:", res.body);
throw new Error("Expected success.data to be an array but got something else or undefined");
}
if (res.body.success.data.length < 1) {
throw new Error("Should have returned at least one result");
}
},


};
6 changes: 3 additions & 3 deletions v2/units.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,10 +582,10 @@ module.exports = function (req, res, next, cb) {
LEFT JOIN macrostrat.lookup_strat_names ON lookup_strat_names.strat_name_id=unit_strat_names.strat_name_id
LEFT JOIN macrostrat.unit_notes ON unit_notes.unit_id=units.id
WHERE ${where}
${orderby.length > 0 ? `ORDER BY ${orderby.join(", ")} ASC` : ""}
${limit})
${orderby.length > 0 ? `ORDER BY ${orderby.join(", ")} ASC` : ""})
SELECT * FROM orig_query
ORDER BY t_age ASC`
ORDER BY t_age ASC
${limit}`

larkin.queryPg("burwell", sql, params, function (error, result) {
if (error) {
Expand Down

0 comments on commit 1211853

Please sign in to comment.