diff --git a/internal/cli/check_test.go b/test/check_test.go similarity index 100% rename from internal/cli/check_test.go rename to test/check_test.go diff --git a/internal/cli/create_test.go b/test/create_test.go similarity index 100% rename from internal/cli/create_test.go rename to test/create_test.go diff --git a/internal/cli/eject_test.go b/test/eject_test.go similarity index 100% rename from internal/cli/eject_test.go rename to test/eject_test.go diff --git a/internal/cli/execute_test.go b/test/execute_test.go similarity index 100% rename from internal/cli/execute_test.go rename to test/execute_test.go diff --git a/test/check-file-origin.feature b/test/features/check-file-origin.feature similarity index 100% rename from test/check-file-origin.feature rename to test/features/check-file-origin.feature diff --git a/test/check-recipes.feature b/test/features/check-recipes.feature similarity index 100% rename from test/check-recipes.feature rename to test/features/check-recipes.feature diff --git a/test/create-recipes.feature b/test/features/create-recipes.feature similarity index 100% rename from test/create-recipes.feature rename to test/features/create-recipes.feature diff --git a/test/eject.feature b/test/features/eject.feature similarity index 100% rename from test/eject.feature rename to test/features/eject.feature diff --git a/test/execute-recipes.feature b/test/features/execute-recipes.feature similarity index 100% rename from test/execute-recipes.feature rename to test/features/execute-recipes.feature diff --git a/test/jalapenoignore.feature b/test/features/jalapenoignore.feature similarity index 100% rename from test/jalapenoignore.feature rename to test/features/jalapenoignore.feature diff --git a/test/recipe-tests.feature b/test/features/recipe-tests.feature similarity index 100% rename from test/recipe-tests.feature rename to test/features/recipe-tests.feature diff --git a/test/recipes-as-oci-artifacts.feature b/test/features/recipes-as-oci-artifacts.feature similarity index 92% rename from test/recipes-as-oci-artifacts.feature rename to test/features/recipes-as-oci-artifacts.feature index 8279b82c..40832083 100644 --- a/test/recipes-as-oci-artifacts.feature +++ b/test/features/recipes-as-oci-artifacts.feature @@ -12,13 +12,14 @@ Feature: Recipes as OCI artifacts Scenario: Pull a recipe from OCI repository Given a recipes directory + And a project directory And a recipe "foo" And recipe "foo" generates file "README.md" with content "initial" And a local OCI registry And the recipe "foo" is pushed to the local OCI repository "foo:v0.0.1" When I pull the recipe "foo" from the local OCI repository "foo:v0.0.1" Then no errors were printed - And the recipes directory should contain recipe "foo" + And the project directory should contain file "foo/recipe.yml" Scenario: Push a recipe to OCI repository with authentication Given a recipes directory @@ -30,13 +31,14 @@ Feature: Recipes as OCI artifacts Scenario: Pull a recipe from OCI repository with authentication Given a recipes directory + And a project directory And a recipe "foo" And recipe "foo" generates file "README.md" with content "initial" And a local OCI registry with authentication And the recipe "foo" is pushed to the local OCI repository "foo:v0.0.1" When I pull the recipe "foo" from the local OCI repository "foo:v0.0.1" Then no errors were printed - And the recipes directory should contain recipe "foo" + And the project directory should contain file "foo/recipe.yml" Scenario: Try to push a recipe to OCI repository without authentication Given a recipes directory @@ -49,6 +51,7 @@ Feature: Recipes as OCI artifacts Scenario: Try to pull a recipe from OCI repository which not exist Given a recipes directory + And a project directory And a local OCI registry with authentication When I pull the recipe "foo" from the local OCI repository "foo:v0.0.1" Then CLI produced an error "recipe not found" diff --git a/test/upgrade-recipe.feature b/test/features/upgrade-recipe.feature similarity index 100% rename from test/upgrade-recipe.feature rename to test/features/upgrade-recipe.feature diff --git a/test/validate-recipe.feature b/test/features/validate-recipe.feature similarity index 100% rename from test/validate-recipe.feature rename to test/features/validate-recipe.feature diff --git a/internal/cli/cmds_test.go b/test/main_test.go similarity index 98% rename from internal/cli/cmds_test.go rename to test/main_test.go index 6eeb4f1a..363196eb 100644 --- a/internal/cli/cmds_test.go +++ b/test/main_test.go @@ -44,6 +44,7 @@ type ( cmdStdErrCtxKey struct{} cmdAdditionalFlagsCtxKey struct{} dockerResourcesCtxKey struct{} + scenarioNameCtxKey struct{} ) type OCIRegistry struct { @@ -117,6 +118,7 @@ func TestFeatures(t *testing.T) { ctx = context.WithValue(ctx, cmdAdditionalFlagsCtxKey{}, make(map[string]string)) ctx = context.WithValue(ctx, dockerResourcesCtxKey{}, []*dockertest.Resource{}) ctx = context.WithValue(ctx, cmdStdInCtxKey{}, NewBlockBuffer()) + ctx = context.WithValue(ctx, scenarioNameCtxKey{}, sc.Name) return ctx, nil }) @@ -128,7 +130,7 @@ func TestFeatures(t *testing.T) { Strict: true, Concurrency: 8, Format: "pretty", - Paths: []string{"../../test"}, + Paths: []string{"./features"}, TestingT: t, }, } @@ -289,9 +291,14 @@ func bufferKeysToInput(ctx context.Context, keys string) (context.Context, error func aRecipe(ctx context.Context, recipeName string) (context.Context, error) { dir := ctx.Value(recipesDirectoryPathCtxKey{}).(string) + scenarioName := ctx.Value(scenarioNameCtxKey{}).(string) + re := recipe.NewRecipe() re.Name = recipeName re.Version = "v0.0.1" + re.Description = scenarioName + + fmt.Println(dir) if err := re.Save(filepath.Join(dir, recipeName)); err != nil { return ctx, err diff --git a/internal/cli/pull_test.go b/test/pull_test.go similarity index 91% rename from internal/cli/pull_test.go rename to test/pull_test.go index 6205dd64..1d8c0aa3 100644 --- a/internal/cli/pull_test.go +++ b/test/pull_test.go @@ -13,12 +13,14 @@ func AddPullSteps(s *godog.ScenarioContext) { } func iPullRecipe(ctx context.Context, recipeName, repoName string) (context.Context, error) { + dir := ctx.Value(projectDirectoryPathCtxKey{}).(string) ociRegistry := ctx.Value(ociRegistryCtxKey{}).(OCIRegistry) configDir, configFileExists := ctx.Value(dockerConfigDirectoryPathCtxKey{}).(string) args := []string{ "pull", filepath.Join(ociRegistry.Resource.GetHostPort("5000/tcp"), repoName), + fmt.Sprintf("--dir=%s", dir), } if ociRegistry.TLSEnabled { diff --git a/internal/cli/push_test.go b/test/push_test.go similarity index 100% rename from internal/cli/push_test.go rename to test/push_test.go diff --git a/internal/cli/test_test.go b/test/test_test.go similarity index 100% rename from internal/cli/test_test.go rename to test/test_test.go diff --git a/internal/cli/upgrade_test.go b/test/upgrade_test.go similarity index 100% rename from internal/cli/upgrade_test.go rename to test/upgrade_test.go diff --git a/internal/cli/validate_test.go b/test/validate_test.go similarity index 100% rename from internal/cli/validate_test.go rename to test/validate_test.go diff --git a/internal/cli/why_test.go b/test/why_test.go similarity index 100% rename from internal/cli/why_test.go rename to test/why_test.go