Skip to content

Commit 02b2d12

Browse files
committed
test: start testing remotes
Now we can do refactors!
1 parent 964ce65 commit 02b2d12

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

test/cctm.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ echo "TAP version 14" > "$SOURCE_DIR"/tap_results.txt
1515

1616
COMPUTER_DIR="$DATA_DIR/computer/0"
1717
cp "$SOURCE_DIR"/test/settings "$COMPUTER_DIR"/.settings
18-
mkdir -p "$COMPUTER_DIR"/{lib,bin}
18+
mkdir -p "$COMPUTER_DIR"/{lib,bin,etc/unicorn/remotes,etc/unicorn/packages/installed}
1919
cp -r "$SOURCE_DIR/unicorn" "$COMPUTER_DIR/lib"
2020
cp "$SOURCE_DIR/vendor/semver/semver.lua" "$COMPUTER_DIR/lib"
2121
cp "$SOURCE_DIR/vendor/sha256.lua" "$COMPUTER_DIR/lib"
2222
cp "$SOURCE_DIR/vendor/mcfly.lua" "$COMPUTER_DIR/bin/mcfly.lua"
2323

24+
echo "https://unicornpkg.github.io/unicornpkg-main" > "$COMPUTER_DIR/etc/unicorn/remotes/90-main.txt"
25+
2426
cp -r "$SOURCE_DIR" "$COMPUTER_DIR/source"
2527

2628
craftos --directory "$DATA_DIR" --headless --exec "shell.run('bin/mcfly.lua source/test/unicorn/'); os.shutdown()"

test/global.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"http_blacklist" : [
1818

1919
],
20-
"http_enable" : false,
20+
"http_enable" : true,
2121
"http_max_download" : 16777216,
2222
"http_max_requests" : 16,
2323
"http_max_upload" : 4194304,
@@ -28,7 +28,8 @@
2828
"http_timeout" : 30000,
2929
"http_websocket_enabled" : true,
3030
"http_whitelist" : [
31-
"*"
31+
"unicornpkg.github.io",
32+
"pastebin.com"
3233
],
3334
"ignoreHotkeys" : false,
3435
"initialComputer" : 0,

test/unicorn/remote_spec.lua

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package.path = "/lib/?.lua;/lib/?;/lib/?/init.lua;" .. package.path
2+
3+
describe("remote", function()
4+
it("require('unicorn.remote') returns a table", function()
5+
expect(require("unicorn.remote")):type("table")
6+
end)
7+
it("can install a package from a remote", function()
8+
print("hi")
9+
local unicornRemote = require("unicorn.remote")
10+
local unicornCore = require("unicorn.core")
11+
unicornRemote.install("ink")
12+
expect(fs.exists("/etc/unicorn/packages/installed/ink")):equals(true)
13+
expect(unicornCore.uninstall("ink")):equals(true)
14+
end)
15+
end)

0 commit comments

Comments
 (0)