-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patherrors.test.osl
More file actions
34 lines (28 loc) · 1.34 KB
/
Copy patherrors.test.osl
File metadata and controls
34 lines (28 loc) · 1.34 KB
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
34
import "std:testing"
import "std:db"
import "std:sync"
import "std:serve"
import "std:fs"
string path = "/tmp/mistwarp-errors-" ++ timestamp.toStr() ++ ".db"
auto testDb = db.open(path)
*db.Collection errorDocs = testDb.collection("site_errors")
def randomString(number length) string (
return "unused"
)
def putDocument(*db.Collection docs, string id, object entry) boolean (
return false
)
import "./errors.osl"
testing.assert(shouldIgnoreSiteError("unsandboxed is not defined"), "ignores extension ReferenceError")
testing.assert(shouldIgnoreSiteError("ReferenceError: unsandboxed is not defined"), "ignores prefixed extension ReferenceError")
testing.assert(shouldIgnoreSiteError("Can't find variable: unsandboxed"), "ignores Safari extension ReferenceError")
testing.assert(shouldIgnoreSiteError(" UNSANDBOXED IS NOT DEFINED "), "normalizes case and whitespace")
testing.assert(!shouldIgnoreSiteError("Hyper Sense must run unsandboxed"), "retains other extension errors")
for i 250 (
errorDocs.insertOne({_id: "e" ++ i.toStr(), resolved: i % 2 == 0, created: i})
)
testing.assert(deleteAllSiteErrors() == 250, "deletes beyond the 200-entry response limit")
testing.assert(errorDocs.count({}) == 0, "deletes both open and resolved errors")
testing.assert(deleteAllSiteErrors() == 0, "deleting an empty collection succeeds")
testDb.close()
fs.remove(path)