Added test to the simple db lib, and depending on config, exclude or not json or memory database.
This commit is contained in:
38
examples/rest/restbucks_CRUD/support/simple_db/tests/a.e
Normal file
38
examples/rest/restbucks_CRUD/support/simple_db/tests/a.e
Normal file
@@ -0,0 +1,38 @@
|
||||
note
|
||||
description: "Summary description for {A}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
A
|
||||
|
||||
create
|
||||
make_with_name
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_with_name (n: STRING)
|
||||
do
|
||||
name := n
|
||||
create items.make (0)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: STRING
|
||||
|
||||
count: INTEGER
|
||||
|
||||
items: ARRAYED_LIST [B]
|
||||
|
||||
feature -- Element change
|
||||
|
||||
extend (b: B)
|
||||
do
|
||||
items.extend (b)
|
||||
count := items.count
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
30
examples/rest/restbucks_CRUD/support/simple_db/tests/b.e
Normal file
30
examples/rest/restbucks_CRUD/support/simple_db/tests/b.e
Normal file
@@ -0,0 +1,30 @@
|
||||
note
|
||||
description: "Summary description for {B}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
B
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature
|
||||
|
||||
make (k: STRING; b: BOOLEAN; v: STRING)
|
||||
do
|
||||
key := k
|
||||
value := v
|
||||
state := b
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
key: STRING
|
||||
|
||||
value: STRING
|
||||
|
||||
state: BOOLEAN
|
||||
|
||||
end
|
||||
@@ -0,0 +1,53 @@
|
||||
note
|
||||
description: "Summary description for {TEST_BASIC_DB_I}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
TEST_BASIC_DB_I
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
|
||||
feature -- Factory
|
||||
|
||||
new_object: ANY
|
||||
local
|
||||
a: A
|
||||
b: B
|
||||
do
|
||||
create a.make_with_name ("Test")
|
||||
create b.make ("foo", True, "test-foo")
|
||||
a.extend (b)
|
||||
create b.make ("bar", True, "test-bar")
|
||||
a.extend (b)
|
||||
Result := a
|
||||
end
|
||||
|
||||
same_object (a,b: like new_object): BOOLEAN
|
||||
local
|
||||
b1,b2: B
|
||||
do
|
||||
if attached {A} a as l_a1 and attached {A} b as l_a2 then
|
||||
Result := l_a1.name.same_string (l_a2.name) and
|
||||
l_a1.count = l_a2.count
|
||||
if Result then
|
||||
from
|
||||
l_a1.items.start
|
||||
l_a2.items.start
|
||||
until
|
||||
not Result or l_a1.items.after or l_a2.items.after
|
||||
loop
|
||||
b1 := l_a1.items.item
|
||||
b2 := l_a1.items.item
|
||||
|
||||
l_a1.items.forth
|
||||
l_a2.items.forth
|
||||
end
|
||||
Result := Result and l_a1.items.after = l_a2.items.after
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,47 @@
|
||||
note
|
||||
description: "Summary description for {TEST_JSON_DB}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
TEST_JSON_DB
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
|
||||
TEST_BASIC_DB_I
|
||||
|
||||
feature -- Test routines
|
||||
|
||||
test_json_db
|
||||
-- New test routine
|
||||
local
|
||||
db: BASIC_JSON_FS_DATABASE
|
||||
obj: like new_object
|
||||
cl: CELL [detachable READABLE_STRING_GENERAL]
|
||||
l_type: TYPE [detachable ANY]
|
||||
l_id: detachable READABLE_STRING_GENERAL
|
||||
do
|
||||
create db.make (create {PATH}.make_from_string ("json-db"))
|
||||
db.serialization.set_pretty_printing
|
||||
db.serialization.register_default (create{JSON_REFLECTOR_SERIALIZATION})
|
||||
|
||||
obj := new_object
|
||||
l_type := obj.generating_type
|
||||
create cl.put ("0")
|
||||
db.save (l_type, obj, cl)
|
||||
l_id := cl.item
|
||||
assert ("new id", l_id /= Void and then not l_id.is_whitespace)
|
||||
if l_id /= Void then
|
||||
assert ("has previous entry", db.has (l_type, l_id))
|
||||
if attached db.item (l_type, l_id) as l_stored_obj then
|
||||
assert ("same object", same_object (l_stored_obj, obj))
|
||||
else
|
||||
assert ("found", False)
|
||||
end
|
||||
end
|
||||
|
||||
db.wipe_out
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,47 @@
|
||||
note
|
||||
description: "Summary description for {TEST_MEMORY_DB}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
TEST_MEMORY_DB
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
|
||||
TEST_BASIC_DB_I
|
||||
|
||||
feature -- Test routines
|
||||
|
||||
test_memory_db
|
||||
-- New test routine
|
||||
local
|
||||
db: BASIC_MEMORY_DATABASE
|
||||
obj: like new_object
|
||||
cl: CELL [detachable READABLE_STRING_GENERAL]
|
||||
l_type: TYPE [detachable ANY]
|
||||
l_id: detachable READABLE_STRING_GENERAL
|
||||
do
|
||||
create db.make
|
||||
obj := new_object
|
||||
l_type := obj.generating_type
|
||||
create cl.put ("0")
|
||||
db.save (l_type, obj, cl)
|
||||
l_id := cl.item
|
||||
assert ("new id", l_id /= Void and then not l_id.is_whitespace)
|
||||
if l_id /= Void then
|
||||
assert ("has previous entry", db.has (l_type, l_id))
|
||||
if attached db.item (l_type, l_id) as l_stored_obj then
|
||||
assert ("same object", l_stored_obj.is_deep_equal (obj))
|
||||
else
|
||||
assert ("found", False)
|
||||
end
|
||||
end
|
||||
db.wipe_out
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
note
|
||||
description: "[
|
||||
Eiffel tests that can be executed by testing tool.
|
||||
]"
|
||||
author: "EiffelStudio test wizard"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
testing: "type/manual"
|
||||
|
||||
class
|
||||
TEST_SED_DB
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
|
||||
TEST_BASIC_DB_I
|
||||
|
||||
feature -- Test routines
|
||||
|
||||
test_sed_db
|
||||
-- New test routine
|
||||
local
|
||||
db: BASIC_SED_FS_DATABASE
|
||||
obj: like new_object
|
||||
cl: CELL [detachable READABLE_STRING_GENERAL]
|
||||
l_type: TYPE [detachable ANY]
|
||||
l_id: detachable READABLE_STRING_GENERAL
|
||||
do
|
||||
create db.make (create {PATH}.make_from_string ("sed-db"))
|
||||
obj := new_object
|
||||
l_type := obj.generating_type
|
||||
create cl.put ("0")
|
||||
db.save (l_type, obj, cl)
|
||||
l_id := cl.item
|
||||
assert ("new id", l_id /= Void and then not l_id.is_whitespace)
|
||||
if l_id /= Void then
|
||||
assert ("has previous entry", db.has (l_type, l_id))
|
||||
if attached db.item (l_type, l_id) as l_stored_obj then
|
||||
assert ("same object", l_stored_obj.is_deep_equal (obj))
|
||||
else
|
||||
assert ("found", False)
|
||||
end
|
||||
end
|
||||
db.wipe_out
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-15-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.eiffel.com/developers/xml/configuration-1-15-0.xsd" name="test_simple_db" uuid="2A955961-2B7F-4075-BD05-F75225D8A711">
|
||||
<target name="test_simple_db">
|
||||
<file_rule>
|
||||
<exclude>/\.svn$</exclude>
|
||||
<exclude>/\.git$</exclude>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
</file_rule>
|
||||
<root class="ANY" feature="default_create"/>
|
||||
<option warning="true" void_safety="all">
|
||||
</option>
|
||||
<setting name="concurrency" value="scoop"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf"/>
|
||||
<library name="simple_db" location="..\simple_db-safe.ecf" readonly="False"/>
|
||||
<library name="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>
|
||||
<cluster name="tests" location=".\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/.*json.*\.e$</exclude>
|
||||
<condition>
|
||||
<version type="compiler" max="17.0.0.0"/>
|
||||
</condition>
|
||||
</file_rule>
|
||||
<file_rule>
|
||||
<exclude>/.*memory.*\.e$</exclude>
|
||||
<condition>
|
||||
<concurrency value="scoop"/>
|
||||
</condition>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
</target>
|
||||
<target name="test_simple_db_st" extends="test_simple_db">
|
||||
<setting name="concurrency" value="none"/>
|
||||
</target>
|
||||
</system>
|
||||
|
||||
Reference in New Issue
Block a user