summaryrefslogtreecommitdiff
path: root/jstests/geo_invalid_polygon.js
blob: af5545b781975660f5a6ec1ab7eb5ca797bf73a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// With invalid geometry, error message should include _id
// SERVER-8992
t = db.geo_invalid_polygon;
t.drop();

// Self-intersecting polygon, triggers
// "Exterior shell of polygon is invalid".
var geometry = {
    type: "Polygon",
    coordinates: [
        [
            [ 0, 0 ],
            [ 0, 1 ],
            [ 1, 1 ],
            [-2,-1 ],
            [ 0, 0 ]
        ]
    ]
};

t.insert({_id: 42, geometry: geometry});
t.createIndex({geometry: '2dsphere'});
var gleResult = db.getLastErrorCmd(1);

// Verify that we triggered the error we're trying to test.
assert.eq(16755, gleResult.code);

// Document's _id should be in error message.
assert(
    -1 != gleResult.err.indexOf('42'),
    "Error message didn't contain document _id.\nMessage: \"" + gleResult.err
    + '"\n'
);