Skip to content

Commit c85feef

Browse files
committed
gel cli tests
1 parent 32a02ff commit c85feef

File tree

4 files changed

+65
-0
lines changed

4 files changed

+65
-0
lines changed

test/gel-cli/_default.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# This is the default test script that tests everything
6+
# It is not run as a scenario, but is run by other test scripts.
7+
8+
# Optional: Import test library
9+
source dev-container-features-test-lib
10+
11+
# check that the command is available
12+
check "help" bash -c "gel --help | grep 'Usage'"
13+
14+
# make sure gel directories match up with our expectations
15+
check "gel cli data dir" bash -c "test \"$(gel info --get data-dir)\" = $HOME/.local/share/gel/data/"
16+
check "gel cli config dir" bash -c "test \"$(gel info --get config-dir)\" = $HOME/.config/gel/"
17+
18+
# check that data directories exist
19+
check "~/.local/share/gel exists" bash -c "ls -la ~/.local/share | grep 'gel'"
20+
check "/dc/gel-cli/data exists" bash -c "ls -la /dc/gel-cli | grep 'data'"
21+
22+
# check that config directories exist
23+
check "~/.config/gel exists" bash -c "ls -la ~/.config | grep 'gel'"
24+
check "/dc/gel-cli exists" bash -c "ls -la /dc/gel-cli | grep 'config'"
25+
26+
# check that the folders are owned by the user
27+
# https://askubuntu.com/a/175060
28+
# $USER is empty when running as root, so we use $(whoami)
29+
echo "Checking ownership of ~/.local/share/gel/data and /dc/gel-cli/data (ensure it is owned by $(whoami))"
30+
31+
check "~/.local/share/gel owned by user" bash -c "test \"$(stat -c "%U" ~/.local/share/gel)\" = $(whoami)"
32+
check "/dc/gel-cli/data owned by user" bash -c "test \"$(stat -c "%U" /dc/gel-cli/data)\" = $(whoami)"
33+
34+
check "~/.config/gel owned by user" bash -c "test \"$(stat -c "%U" ~/.config/gel)\" = $(whoami)"
35+
check "/dc/gel-cli/config owned by user" bash -c "test \"$(stat -c "%U" /dc/gel-cli/config)\" = $(whoami)"
36+
37+
# Report result
38+
reportResults

test/gel-cli/scenarios.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"with_node": {
3+
"image": "mcr.microsoft.com/devcontainers/javascript-node:1-18",
4+
"features": {
5+
"gel-cli": {}
6+
}
7+
}
8+
}

test/gel-cli/test.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Optional: Import test library
6+
source dev-container-features-test-lib
7+
8+
# NOTE: this is an "auto-generated" test, which means it will be
9+
# executed against an auto-generated devcontainer.json that
10+
# includes the feature with no options
11+
12+
./_default.sh

test/gel-cli/with_node.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Run default test script (in same folder)
6+
# See: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/test/azure-cli/install_extensions_bookworm.sh
7+
./_default.sh

0 commit comments

Comments
 (0)