1
1
mirror of https://github.com/mcuadros/ascode synced 2024-11-23 17:32:09 +01:00
ascode/starlark/module/os/testdata/test.star
Máximo Cuadros 98979397bb starlark/module: os module implementation and tests
Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
2019-07-10 01:23:15 +02:00

32 lines
711 B
Plaintext

load('os', 'os')
load('assert.star', 'assert')
key = "HELLO"
value = "world"
os.setenv(key, value)
assert.eq(os.getenv(key), value)
content = "hello world\n"
assert.eq(os.write_file("/tmp/plain.txt", content), None)
assert.eq(os.read_file("/tmp/plain.txt"), content)
assert.eq(os.write_file("/tmp/perms.txt", content=content, perms=0o777), None)
assert.eq(os.read_file("/tmp/perms.txt"), content)
os.mkdir("foo", 0o755)
os.remove("foo")
assert.ne(os.getwd(), "")
os.chdir("/tmp")
assert.eq(os.getwd(), "/tmp")
os.mkdir_all("foo/bar", 0o755)
os.rename("foo", "bar")
os.remove_all("bar")
def deleteNotExistant(): os.remove("foo")
assert.fails(deleteNotExistant, "remove foo: no such file or directory")