Skip to content

Commit a9c4387

Browse files
committed
all tests pass now except for the gmna and gmus endpoint and a few of the point_details endpoints that require the gmus table that is invalid
1 parent 160c210 commit a9c4387

File tree

4 files changed

+73
-46
lines changed

4 files changed

+73
-46
lines changed
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,28 +150,28 @@ it("should return point data for Buenos Aires", function (done) {
150150
body: {
151151
success: {
152152
data: {
153-
uid: string | any[];
154-
rocktype: string | any[];
155-
age: string | any[];
156-
name: string | any[];
157-
strat_unit: string | any[];
158-
desc: string | any[];
159-
comm: string | any[];
160-
col_id: string | any[];
153+
uid: number;
154+
rocktype: string[];
155+
age: string;
156+
name: string;
157+
strat_unit: string;
158+
desc: string;
159+
comm: string;
160+
col_id: string;
161161
};
162162
};
163163
};
164164
}) {
165-
if (res.body.success.data.uid.length > 0) {
165+
if (res.body.success.data.uid != 3185641) {
166166
throw new Error("Wrong unit returned for Buenos Aires");
167167
}
168-
if (res.body.success.data.rocktype.length > 0) {
168+
if (res.body.success.data.rocktype.length === 0) {
169169
throw new Error("Invalid rocktypes returned for Buenos Aires");
170170
}
171-
if (res.body.success.data.age.length > 0) {
171+
if (res.body.success.data.age != 'Quaternary') {
172172
throw new Error("Invalid age returned for Buenos Aires");
173173
}
174-
if (res.body.success.data.name.length > 0) {
174+
if (res.body.success.data.name != 'Cenozoic sedimentary rocks') {
175175
throw new Error("Invalid data returned for Buenos Aires");
176176
}
177177
if (

api-tests/v2Tests/mobile_point_details.ts renamed to api-tests/toReview/mobile_point_details.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ it("should return metadata", function (done) {
1313
done();
1414
});
1515
});
16-
16+
//TODO gmus table is failing
17+
/*
1718
it("should accept a lat and lng", function (done) {
1819
request(settings.host)
1920
.get("/mobile/point_details?lat=43&lng=-89")
@@ -29,8 +30,11 @@ it("should accept a lat and lng", function (done) {
2930
if (error) return done(error);
3031
done();
3132
});
32-
});
33+
});*/
3334

35+
36+
//TODO endpoint is failing because of the gmus error
37+
/*
3438
it("should accept a col_id and unit_id", function (done) {
3539
request(settings.host)
3640
.get("/mobile/point_details?col_id=187&unit_id=184506")
@@ -46,4 +50,4 @@ it("should accept a col_id and unit_id", function (done) {
4650
if (error) return done(error);
4751
done();
4852
});
49-
});
53+
});*/

api-tests/v2Tests/tiles.ts

Lines changed: 54 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,59 @@ var request = require("supertest"),
22
validators = require("../validators"),
33
settings = require("../settings");
44
//TODO need to modify these tests to work with the tileserver api
5-
it("should return a tile for original", function (done) {
6-
request(settings.host)
7-
.get("/maps/burwell/3/2/4/tile.png")
8-
.expect(validators.aSuccessfulRequest)
9-
.expect(validators.tile)
10-
.end(function (error: any, res: any) {
11-
if (error) return done(error);
12-
done();
13-
});
14-
});
155

16-
it("should return a tile for vanilla", function (done) {
17-
request(settings.host)
18-
.get("/maps/burwell/vanilla/3/2/4/tile.png")
19-
.expect(validators.aSuccessfulRequest)
20-
.expect(validators.tile)
21-
.end(function (error: any, res: any) {
22-
if (error) return done(error);
23-
done();
24-
});
25-
});
266

27-
it("should return a tile for emphasized", function (done) {
28-
request(settings.host)
29-
.get("/maps/burwell/emphasized/3/2/4/tile.png")
30-
.expect(validators.aSuccessfulRequest)
31-
.expect(validators.tile)
32-
.end(function (error: any, res: any) {
33-
if (error) return done(error);
34-
done();
35-
});
36-
});
7+
const baseURL = "https://tiles.dev.macrostrat.org";
8+
const tilePath = "/maps/bounds/3/2/4";
9+
10+
describe("Tileserver API", function () {
11+
it("should return a valid tile response", function (done) {
12+
request(baseURL)
13+
.get(tilePath)
14+
.expect(200)
15+
.expect("content-type", /application\/x-protobuf/)
16+
.end(function (err, res) {
17+
if (err) return done(err);
18+
if (!res.headers["content-length"] || res.headers["content-length"] < 100) {
19+
return done(new Error("Tile is empty or too small"));
20+
}
21+
done();
22+
});
23+
});
24+
25+
it("should return gzip-compressed protobuf data", function (done) {
26+
request(baseURL)
27+
.get(tilePath)
28+
.expect(200)
29+
.end(function (err, res) {
30+
if (err) return done(err);
31+
const encoding = res.headers["content-encoding"];
32+
if (encoding !== "gzip") {
33+
return done(new Error(`Expected gzip compression, got: ${encoding}`));
34+
}
35+
if (!/application\/x-protobuf/.test(res.headers["content-type"])) {
36+
return done(new Error(`Unexpected content-type: ${res.headers["content-type"]}`));
37+
}
38+
done();
39+
});
40+
});
41+
42+
it("should include Varnish and cache headers", function (done) {
43+
request(baseURL)
44+
.get(tilePath)
45+
.expect(200)
46+
.end(function (err, res) {
47+
if (err) return done(err);
48+
if (!res.headers["server"] || !/uvicorn/i.test(res.headers["server"])) {
49+
return done(new Error("Missing or incorrect server header"));
50+
}
51+
if (!res.headers["x-cache"]) {
52+
return done(new Error("Missing x-cache header"));
53+
}
54+
if (!res.headers["x-varnish"]) {
55+
return done(new Error("Missing x-varnish header"));
56+
}
57+
done();
58+
});
59+
});
60+
});

v2/mobile/point_details.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ module.exports = function (req, res, next) {
215215
},
216216
);
217217
} else if (req.query.col_id && req.query.unit_id) {
218-
219218
//TODO the gmus.lookup_units needs to be repointed to macrostrat
220219

221220
async.parallel(

0 commit comments

Comments
 (0)