# 
# Copyright © 2024 Thomas von Dein
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# 

# simple file, we cannot use redirection here, so dd is our friend
exec dd if=/dev/random of=file.txt count=5 bs=10

# add file to db
exec anydb -f test.db set datum -r file.txt

# check for existence
exec anydb -f test.db get datum -o out.txt
exists out.txt

# check if its filled (50 bytes == count=5 x bs=10)
exec ls -l out.txt
stdout 50

# look if it's inside the db
exec anydb -f test.db ls
stdout datum.*binary-content

# do the same thing with text content, start with a new text entry
exec anydb -f test.db set feed alpha

# which we write to a file
exec anydb -f test.db get feed -o out2.txt
exists out2.txt

# check if its filled (5 bytes + newline)
exec ls -l out2.txt
stdout 6

# compare content
exec cat out2.txt
stdout alpha


