Skip to content

Commit

Permalink
test: skip feature tests using Docker on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
majori committed Nov 15, 2024
1 parent bd10cc9 commit d490095
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ jobs:
go-version: "1.23"

- name: Run tests
if: matrix.os == 'ubuntu-latest'
run: go test ./...

- name: Run tests (skip tests using Docker)
if: matrix.os == 'windows-latest'
run: go test ./... --godog.tags=~@docker
11 changes: 10 additions & 1 deletion test/features/check-recipes.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Feature: Check for new recipe versions

@registry
Scenario: Find newer version for a recipe
Given a recipe "foo"
And recipe "foo" generates file "README.md" with content "initial"
Expand All @@ -16,6 +16,7 @@ Feature: Check for new recipe versions
Then CLI produced an output "new versions found: v0\.0\.2"
Then CLI produced an output "To upgrade recipes to the latest version run:\n (.*) upgrade oci://localhost:\d+/foo:v0.0.2\n"

@registry
Scenario: Find multiple newer version for a recipe
Given a recipe "foo"
And recipe "foo" generates file "README.md" with content "initial"
Expand All @@ -33,6 +34,7 @@ Feature: Check for new recipe versions
Then CLI produced an output "new versions found: v0\.0\.2, v0\.0\.3"
Then CLI produced an output "To upgrade recipes to the latest version run:\n (.*) upgrade oci://localhost:\d+/foo:v0\.0\.3\n"

@registry
Scenario: Find newer version for multiple recipes
Given a recipe "foo"
And recipe "foo" generates file "foo.md" with content "initial"
Expand All @@ -59,6 +61,7 @@ Feature: Check for new recipe versions
Then CLI produced an output "foo: new versions found: v0\.0\.2"
And CLI produced an output "bar: new versions found: v0\.0\.2"

@registry
Scenario: Unable to find newer recipe versions
Given a recipe "foo"
And recipe "foo" generates file "README.md" with content "initial"
Expand All @@ -73,6 +76,7 @@ Feature: Check for new recipe versions
And I check new versions for recipe "foo"
Then CLI produced an output "no new versions found"

@registry
Scenario: Unable to find newer recipe versions for all recipes
Given a recipe "foo"
And recipe "foo" generates file "foo.md" with content "initial"
Expand All @@ -95,6 +99,7 @@ Feature: Check for new recipe versions
Then CLI produced an output "foo: new versions found: v0\.0\.2"
And CLI produced an output "bar: no new versions found"

@registry
Scenario: Executing remote recipe automatically adds the repo as source for the sauce
Given a recipe "foo"
And recipe "foo" generates file "README.md" with content "initial"
Expand All @@ -108,6 +113,7 @@ Feature: Check for new recipe versions
And I check new versions for recipe "foo"
Then CLI produced an output "new versions found: v0\.0\.2"

@registry
Scenario: Manually override the check from URL for locally executed recipe
Given a recipe "foo"
And recipe "foo" generates file "README.md" with content "initial"
Expand All @@ -121,6 +127,7 @@ Feature: Check for new recipe versions
Then CLI produced an output "new versions found: v0\.0\.2"
And the sauce in index 0 which should have property "CheckFrom" with value "^oci://localhost:\d+/foo$"

@registry
Scenario: Find and upgrade newer version for recipes
Given a recipe "foo"
And recipe "foo" generates file "README.md" with content "initial"
Expand All @@ -136,6 +143,7 @@ Feature: Check for new recipe versions
Then CLI produced an output "new versions found: v0\.0\.2"
Then CLI produced an output "Upgrade completed"

@registry
Scenario: Find and upgrade newer version for a specific recipe
Given a recipe "foo"
And recipe "foo" generates file "README.md" with content "initial"
Expand All @@ -157,6 +165,7 @@ Feature: Check for new recipe versions
Then CLI produced an output "new versions found: v0\.0\.2"
Then CLI produced an output "Upgrade completed"

@registry
Scenario: Find and upgrade newer versions for multiple recipes
Given a recipe "foo"
And recipe "foo" generates file "foo.md" with content "initial"
Expand Down
1 change: 1 addition & 0 deletions test/features/execute-manifest.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Feature: Execute manifests
And the project directory should contain file "foo.md"
And the project directory should contain file "bar.md"

@registry
Scenario: Execute a manifest with remote recipes
Given a local OCI registry
And a recipe "foo"
Expand Down
1 change: 1 addition & 0 deletions test/features/execute-recipes.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Feature: Execute recipes
And the sauce in index 0 which should have property "Recipe.Name" with value "^foo$"
And the sauce in index 0 which has a valid ID

@registry
Scenario: Execute single recipe from remote registry
Given a recipe "foo"
And recipe "foo" generates file "README.md" with content "initial"
Expand Down
13 changes: 11 additions & 2 deletions test/features/recipes-as-oci-artifacts.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ Feature: Recipes as OCI artifacts
By pushing and pulling recipes as artifacts to OCI compatible repositories, we can improve
recipe availability and discoverability

@registry
Scenario: Push a recipe to OCI repository
Given a recipe "foo"
And recipe "foo" generates file "README.md" with content "initial"
And a local OCI registry
When I push the recipe "foo" to the local OCI repository
Then no errors were printed

@registry
Scenario: Pull a recipe from OCI repository
Given a recipe "foo"
And recipe "foo" generates file "README.md" with content "initial"
Expand All @@ -18,6 +19,7 @@ Feature: Recipes as OCI artifacts
Then no errors were printed
And the project directory should contain file "foo/recipe.yml"

@registry
Scenario: Push a recipe to OCI repository using the 'latest' tag
Given a recipe "foo"
And recipe "foo" generates file "README.md" with content "initial"
Expand All @@ -28,6 +30,7 @@ Feature: Recipes as OCI artifacts
Then no errors were printed
And the project directory should contain file "foo/recipe.yml" with "version: v0.0.1"

@registry
Scenario: Pushing a recipe to OCI repository using the 'latest' tag pushes the version tag also
Given a recipe "foo"
And recipe "foo" generates file "README.md" with content "initial"
Expand All @@ -38,6 +41,7 @@ Feature: Recipes as OCI artifacts
Then no errors were printed
And the project directory should contain file "foo/recipe.yml" with "version: v0.0.1"

@registry
Scenario: Pushing a recipe to OCI repository using the 'latest' tag replaces the previous tag
Given a recipe "foo"
And recipe "foo" generates file "README.md" with content "initial"
Expand All @@ -51,13 +55,15 @@ Feature: Recipes as OCI artifacts
Then no errors were printed
And the project directory should contain file "foo/recipe.yml" with "version: v0.0.2"

@registry
Scenario: Push a recipe to OCI repository with authentication
Given a recipe "foo"
And recipe "foo" generates file "README.md" with content "initial"
And a local OCI registry with authentication
When I push the recipe "foo" to the local OCI repository
Then no errors were printed

@registry
Scenario: Pull a recipe from OCI repository with authentication
Given a recipe "foo"
And recipe "foo" generates file "README.md" with content "initial"
Expand All @@ -66,7 +72,8 @@ Feature: Recipes as OCI artifacts
When I pull recipe from the local OCI repository "foo:v0.0.1"
Then no errors were printed
And the project directory should contain file "foo/recipe.yml"


@registry
Scenario: Try to push a recipe to OCI repository without authentication
Given a recipe "foo"
And recipe "foo" generates file "README.md" with content "initial"
Expand All @@ -75,11 +82,13 @@ Feature: Recipes as OCI artifacts
When I push the recipe "foo" to the local OCI repository
Then CLI produced an error "basic credential not found"

@registry
Scenario: Try to pull a recipe from OCI repository which not exist
Given a local OCI registry with authentication
When I pull recipe from the local OCI repository "foo:v0.0.1"
Then CLI produced an error "recipe not found"

@registry
Scenario: Push a recipe from OCI repository using credentials from config file
Given a recipe "foo"
And recipe "foo" generates file "README.md" with content "initial"
Expand Down
1 change: 1 addition & 0 deletions test/features/upgrade-recipe.feature
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ Feature: Upgrade sauce
And the project directory should contain file "./foo/README.md" with "New version"
And the project directory should contain file "./bar/README.md" with "initial"

@registry
Scenario: Upgrade sauce from remote recipe
Given a local OCI registry
And a recipe "foo"
Expand Down
24 changes: 16 additions & 8 deletions test/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,21 @@ const (
*/

func TestFeatures(t *testing.T) {
opts := &godog.Options{
Format: "pretty",
Strict: true,
Concurrency: runtime.NumCPU(),
Paths: []string{"features"},
TestingT: t,
}

// Skip tests needing OCI registry on Windows because there is no windows/amd64 image available
if runtime.GOOS == "windows" {
opts.Tags = "~@registry"
}

suite := godog.TestSuite{
Options: &godog.Options{
Format: "pretty",
Strict: true,
Concurrency: runtime.NumCPU(),
Paths: []string{"features"},
TestingT: t,
},
Options: opts,
ScenarioInitializer: func(s *godog.ScenarioContext) {
AddCommonSteps(s)

Expand Down Expand Up @@ -335,7 +342,7 @@ func iRemoveFileFromTheRecipe(ctx context.Context, filename, recipeName string)
}

func aLocalOCIRegistry(ctx context.Context) (context.Context, error) {
resource, err := createLocalRegistry(&dockertest.RunOptions{Repository: "registry", Tag: "2"})
resource, err := createLocalRegistry(&dockertest.RunOptions{Repository: "registry", Tag: "2", Platform: "linux/amd64"})
if err != nil {
return ctx, err
}
Expand All @@ -360,6 +367,7 @@ func aLocalOCIRegistryWithAuth(ctx context.Context) (context.Context, error) {
resource, err := createLocalRegistry(&dockertest.RunOptions{
Repository: "registry",
Tag: "2",
Platform: "linux/amd64",
Env: []string{
"REGISTRY_AUTH_HTPASSWD_REALM=jalapeno-test-realm",
fmt.Sprintf("REGISTRY_AUTH_HTPASSWD_PATH=/auth/%s", HTPASSWD_FILENAME),
Expand Down

0 comments on commit d490095

Please sign in to comment.