aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2019-10-11 10:15:58 +0000
committers-ol <s-ol@users.noreply.github.com>2019-10-11 10:15:58 +0000
commite2a4257fc05d37822df2b7bbe0f587645375edf2 (patch)
treeb170a7323f4c080207dd681f66f70ee43fbc01ae /spec
parentadd table to mmm/dom convert (diff)
downloadmmm-e2a4257fc05d37822df2b7bbe0f587645375edf2.tar.gz
mmm-e2a4257fc05d37822df2b7bbe0f587645375edf2.zip
fileders load via get_index rather than list_facets/list_fileders
Diffstat (limited to 'spec')
-rw-r--r--spec/stores_spec.moon70
1 files changed, 68 insertions, 2 deletions
diff --git a/spec/stores_spec.moon b/spec/stores_spec.moon
index 3997ded..742d8c8 100644
--- a/spec/stores_spec.moon
+++ b/spec/stores_spec.moon
@@ -1,3 +1,21 @@
+-- relative imports
+_G.relative = do
+ _require = require
+
+ (base, sub) ->
+ sub = sub or 0
+
+ for i=1, sub
+ base = base\match '^(.*)%.%w+$'
+
+ (name, x) ->
+ if name == '.'
+ name = base
+ else if '.' == name\sub 1, 1
+ name = base .. name
+
+ _require name
+
sort2 = (a, b) ->
{ax, ay}, {bx, by} = a, b
"#{ax}//#{ay}" < "#{bx}//#{by}"
@@ -57,6 +75,51 @@ test_store = (ts) ->
assert.are.same {{'', 'text/markdown'}, {'name', 'alpha'}},
toseq2 ts\list_facets '/hello/world'
+ describe "can get indexes", ->
+ hello_index = {
+ path: '/hello'
+ children: {
+ '/hello/world'
+ }
+ facets: {
+ { name: 'name', type: 'alpha' }
+ }
+ }
+
+ it "for a single level", ->
+ assert.are.same hello_index, ts\get_index '/hello'
+
+
+ root_index = {
+ path: ''
+ children: {
+ hello_index
+ }
+ facets: {}
+ }
+ it "for a limited number of levels", ->
+ assert.are.same root_index, ts\get_index '', 2
+
+ it "recursively", ->
+ hello_index.children[1] = {
+ path: '/hello/world'
+ children: {
+ {
+ path: '/hello/world/again'
+ children: {}
+ facets: {}
+ }
+ }
+ facets: {
+ { name: '', type: 'text/markdown' }
+ { name: 'name', type: 'alpha' }
+ }
+ }
+
+ assert.are.same root_index, ts\get_index '', -1
+
+ it "can get indexes recursively", ->
+
it "can load facets", ->
assert.are.equal 'hello', ts\load_facet '/hello', 'name', 'alpha'
assert.are.equal 'world', ts\load_facet '/hello/world', 'name', 'alpha'
@@ -89,7 +152,10 @@ test_store = (ts) ->
ts\remove_fileder '/hello'
assert.are.same {}, toseq ts\list_all_fileders!
-describe "SQL spec", ->
+ it "can be closed", ->
+ ts\close!
+
+describe "SQL store", ->
import SQLStore from require 'mmm.mmmfs.stores.sql'
test_store SQLStore memory: true
@@ -105,7 +171,7 @@ describe "FS store", ->
assert os.remove root
assert lfs.mkdir root
- test_store LFSStore :root
+ test_store FSStore :root
teardown ->
assert lfs.rmdir root