This commit is contained in:
2023-09-17 19:52:23 +00:00
committed by GitHub
parent 58c753dff1
commit 5958d4a233
22 changed files with 47 additions and 660 deletions

View File

@@ -1,33 +0,0 @@
#!/bin/bash
# The 'test/_global' folder is a special test folder that is not tied to a single feature.
#
# This test file is executed against a running container constructed
# from the value of 'color_and_hello' in the tests/_global/scenarios.json file.
#
# The value of a scenarios element is any properties available in the 'devcontainer.json'.
# Scenarios are useful for testing specific options in a feature, or to test a combination of features.
#
# This test can be run with the following command (from the root of this repo)
# devcontainer features test --global-scenarios-only .
set -e
# Optional: Import test library bundled with the devcontainer CLI
source dev-container-features-test-lib
echo -e "The result of the 'color' command will be:\n"
color
echo -e "The result of the 'hello' command will be:\n"
hello
echo -e "\n"
# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib.
check "check purple is my favorite color" bash -c "color | grep 'my favorite color is purple'"
check "check I am greeting with 'Greetings'" bash -c "hello | grep 'Greetings, $(whoami)'"
# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults

View File

@@ -1,13 +0,0 @@
{
"color_and_hello": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"color": {
"favorite": "purple"
},
"hello": {
"greeting": "Greetings"
}
}
}
}

View File

@@ -1,17 +0,0 @@
#!/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

View File

@@ -1,17 +0,0 @@
#!/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

@@ -1,31 +0,0 @@
#!/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

View File

@@ -1,33 +0,0 @@
{
"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"
}
}
}
}

View File

@@ -1,47 +0,0 @@
#!/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

View File

@@ -1,17 +0,0 @@
#!/bin/bash
# This test file will be executed against one of the scenarios devcontainer.json test that
# includes the 'color' feature with "greeting": "hello" 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 "hello | grep 'hello, $(whoami)!'"
# Report results
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults

View File

@@ -1,10 +0,0 @@
{
"hello": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"hello": {
"greeting": "hello"
}
}
}
}

View File

@@ -1,47 +0,0 @@
#!/bin/bash
# This test file will be executed against an auto-generated devcontainer.json that
# includes the 'hello' 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": {
# "hello": {}
# },
# "remoteUser": "root"
# }
#
# Thus, the value of all options will fall back to the default value in
# the Feature's 'devcontainer-feature.json'.
# For the 'hello' feature, that means the default favorite greeting is 'hey'.
#
# 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 hello \
# --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 "execute command" bash -c "hello | grep 'hey, $(whoami)!'"
# Report results
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults

View File

@@ -1,9 +1,9 @@
{
"hello": {
"wine_specified_version": {
"image": "mcr.microsoft.com/devcontainers/base:debian",
"features": {
"wine": {
"version": "8.15"
"version": "8.5"
}
}
}

View File

@@ -1,47 +1,9 @@
#!/bin/bash
# This test file will be executed against an auto-generated devcontainer.json that
# includes the 'hello' 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": {
# "hello": {}
# },
# "remoteUser": "root"
# }
#
# Thus, the value of all options will fall back to the default value in
# the Feature's 'devcontainer-feature.json'.
# For the 'hello' feature, that means the default favorite greeting is 'hey'.
#
# 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 hello \
# --remote-user root \
# --skip-scenarios \
# --base-image mcr.microsoft.com/devcontainers/base:ubuntu \
# /path/to/this/repo
a#!/bin/bash
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 "execute command" bash -c "hello | grep 'hey, $(whoami)!'"
check "wine exists" wine --version
check
# Report results
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults

View File

@@ -0,0 +1,9 @@
#!/bin/bash
set -e
source dev-container-features-test-lib
check "wine version is same" [[ "$(wine --version | tr -d -c 0-9.)" == *"8.5"* ]]
check
reportResults