Initial commit

This commit is contained in:
2023-09-15 20:25:04 +03:00
committed by GitHub
commit 07e55c1006
22 changed files with 770 additions and 0 deletions

17
test/color/gold.sh Normal file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
# This test file will be executed against one of the scenarios devcontainer.json test that
# includes the 'color' feature with "favorite": "gold" option.
set -e
# Optional: Import test library bundled with the devcontainer CLI
source dev-container-features-test-lib
# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib.
check "execute command" bash -c "color | grep 'my favorite color is gold'"
# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults

17
test/color/green.sh Normal file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
# This test file will be executed against one of the scenarios devcontainer.json test that
# includes the 'color' feature with "favorite": "green" option.
set -e
# Optional: Import test library bundled with the devcontainer CLI
source dev-container-features-test-lib
# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib.
check "execute command" bash -c "color | grep 'my favorite color is green'"
# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults

View File

@@ -0,0 +1,31 @@
#!/bin/bash
# This test file will be executed against after building a container with the
# 'my_favorite_color_is_green' scenario in 'test/test/color/scenarios.json'.
#
# For more information, see: https://github.com/devcontainers/cli/blob/main/docs/features/test.md
#
# This scenario first uses the 'common-utils' Features to add a new user 'octocat'.
# It then installs the 'color' Feature with the FAVORITE option set to 'green' (the default FAVORITE value if none provided is 'red').
#
#
# This test (as well as any of the other scenarios in 'scenarios.json') can be run with the following command:
#
# devcontainer features test \
# --features color \
# --skip-autogenerated \
# /path/to/this/repo
set -e
# Optional: Import test library bundled with the devcontainer CLI
# Provides the 'check' and 'reportResults' commands.
source dev-container-features-test-lib
# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib.
check "validate favorite color" color | grep 'my favorite color is green'
# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults

33
test/color/scenarios.json Normal file
View File

@@ -0,0 +1,33 @@
{
"my_favorite_color_is_green": {
"image": "mcr.microsoft.com/devcontainers/base:focal",
"features": {
"ghcr.io/devcontainers/features/common-utils:1": {
"installZsh": false,
"installOhMyZsh": false,
"upgradePackages": false,
"username": "octocat"
},
"color": {
"favorite": "green"
}
},
"remoteUser": "octocat"
},
"gold": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"color": {
"favorite": "gold"
}
}
},
"green": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"color": {
"favorite": "green"
}
}
}
}

47
test/color/test.sh Normal file
View File

@@ -0,0 +1,47 @@
#!/bin/bash
# This test file will be executed against an auto-generated devcontainer.json that
# includes the 'color' Feature with no options.
#
# For more information, see: https://github.com/devcontainers/cli/blob/main/docs/features/test.md
#
# Eg:
# {
# "image": "<..some-base-image...>",
# "features": {
# "color": {}
# },
# "remoteUser": "root"
# }
#
# Thus, the value of all options will fall back to the default value in the
# Feature's 'devcontainer-feature.json'.
# For the 'color' feature, that means the default favorite color is 'red'.
#
# These scripts are run as 'root' by default. Although that can be changed
# with the '--remote-user' flag.
#
# This test can be run with the following command:
#
# devcontainer features test \
# --features color \
# --remote-user root \
# --skip-scenarios \
# --base-image mcr.microsoft.com/devcontainers/base:ubuntu \
# /path/to/this/repo
set -e
# Optional: Import test library bundled with the devcontainer CLI
# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib
# Provides the 'check' and 'reportResults' commands.
source dev-container-features-test-lib
# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib. Syntax is...
# check <LABEL> <cmd> [args...]
check "validate favorite color" color | grep 'my favorite color is red'
# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults