Skip to content

Commit

Permalink
test(binding/lua): Add more service schema test (#2512)
Browse files Browse the repository at this point in the history
Signed-off-by: owl <[email protected]>
  • Loading branch information
oowl authored Jun 23, 2023
1 parent 95ff8e2 commit cbaa315
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions bindings/lua/test/opendal_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,35 @@ describe("opendal unit test", function()
assert.are.equal(res, false)
end)
end)
describe("opendal memory schema", function()
it("operator function in memory schema", function()
local opendal = require("opendal")
local op, err = opendal.operator.new("memory",{root="/tmp"})
assert.is_nil(err)
assert.is_nil(op:write("test.txt","hello world"))
local res, err = op:read("test.txt")
assert.is_nil(err)
assert.are.equal(res, "hello world")
assert.equal(op:is_exist("test.txt"), true)
assert.is_nil(op:delete("test.txt"))
assert.equal(op:is_exist("test.txt"), false)
end)
it("meta function in memory schema", function()
local opendal = require("opendal")
local op, err = opendal.operator.new("memory",{root="/tmp"})
assert.is_nil(err)
assert.is_nil(op:write("test.txt","hello world"))
local meta, err = op:stat("test.txt")
assert.is_nil(err)
local res, err = meta:content_length()
assert.is_nil(err)
assert.are.equal(res, 11)
local res, err = meta:is_file()
assert.is_nil(err)
assert.are.equal(res, true)
local res, err = meta:is_dir()
assert.is_nil(err)
assert.are.equal(res, false)
end)
end)
end)

0 comments on commit cbaa315

Please sign in to comment.