Skip to content

Commit 87fc7c7

Browse files
committed
refactor(test): move feature tests under /test
1 parent 5ab41fc commit 87fc7c7

21 files changed

+13
-3
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

test/recipes-as-oci-artifacts.feature test/features/recipes-as-oci-artifacts.feature

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ Feature: Recipes as OCI artifacts
1212

1313
Scenario: Pull a recipe from OCI repository
1414
Given a recipes directory
15+
And a project directory
1516
And a recipe "foo"
1617
And recipe "foo" generates file "README.md" with content "initial"
1718
And a local OCI registry
1819
And the recipe "foo" is pushed to the local OCI repository "foo:v0.0.1"
1920
When I pull the recipe "foo" from the local OCI repository "foo:v0.0.1"
2021
Then no errors were printed
21-
And the recipes directory should contain recipe "foo"
22+
And the project directory should contain file "foo/recipe.yml"
2223

2324
Scenario: Push a recipe to OCI repository with authentication
2425
Given a recipes directory
@@ -30,13 +31,14 @@ Feature: Recipes as OCI artifacts
3031

3132
Scenario: Pull a recipe from OCI repository with authentication
3233
Given a recipes directory
34+
And a project directory
3335
And a recipe "foo"
3436
And recipe "foo" generates file "README.md" with content "initial"
3537
And a local OCI registry with authentication
3638
And the recipe "foo" is pushed to the local OCI repository "foo:v0.0.1"
3739
When I pull the recipe "foo" from the local OCI repository "foo:v0.0.1"
3840
Then no errors were printed
39-
And the recipes directory should contain recipe "foo"
41+
And the project directory should contain file "foo/recipe.yml"
4042

4143
Scenario: Try to push a recipe to OCI repository without authentication
4244
Given a recipes directory
@@ -49,6 +51,7 @@ Feature: Recipes as OCI artifacts
4951

5052
Scenario: Try to pull a recipe from OCI repository which not exist
5153
Given a recipes directory
54+
And a project directory
5255
And a local OCI registry with authentication
5356
When I pull the recipe "foo" from the local OCI repository "foo:v0.0.1"
5457
Then CLI produced an error "recipe not found"
File renamed without changes.
File renamed without changes.

internal/cli/cmds_test.go test/main_test.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type (
4444
cmdStdErrCtxKey struct{}
4545
cmdAdditionalFlagsCtxKey struct{}
4646
dockerResourcesCtxKey struct{}
47+
scenarioNameCtxKey struct{}
4748
)
4849

4950
type OCIRegistry struct {
@@ -117,6 +118,7 @@ func TestFeatures(t *testing.T) {
117118
ctx = context.WithValue(ctx, cmdAdditionalFlagsCtxKey{}, make(map[string]string))
118119
ctx = context.WithValue(ctx, dockerResourcesCtxKey{}, []*dockertest.Resource{})
119120
ctx = context.WithValue(ctx, cmdStdInCtxKey{}, NewBlockBuffer())
121+
ctx = context.WithValue(ctx, scenarioNameCtxKey{}, sc.Name)
120122

121123
return ctx, nil
122124
})
@@ -128,7 +130,7 @@ func TestFeatures(t *testing.T) {
128130
Strict: true,
129131
Concurrency: 8,
130132
Format: "pretty",
131-
Paths: []string{"../../test"},
133+
Paths: []string{"./features"},
132134
TestingT: t,
133135
},
134136
}
@@ -289,9 +291,12 @@ func bufferKeysToInput(ctx context.Context, keys string) (context.Context, error
289291

290292
func aRecipe(ctx context.Context, recipeName string) (context.Context, error) {
291293
dir := ctx.Value(recipesDirectoryPathCtxKey{}).(string)
294+
scenarioName := ctx.Value(scenarioNameCtxKey{}).(string)
295+
292296
re := recipe.NewRecipe()
293297
re.Name = recipeName
294298
re.Version = "v0.0.1"
299+
re.Description = scenarioName
295300

296301
if err := re.Save(filepath.Join(dir, recipeName)); err != nil {
297302
return ctx, err

internal/cli/pull_test.go test/pull_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ func AddPullSteps(s *godog.ScenarioContext) {
1313
}
1414

1515
func iPullRecipe(ctx context.Context, recipeName, repoName string) (context.Context, error) {
16+
dir := ctx.Value(projectDirectoryPathCtxKey{}).(string)
1617
ociRegistry := ctx.Value(ociRegistryCtxKey{}).(OCIRegistry)
1718
configDir, configFileExists := ctx.Value(dockerConfigDirectoryPathCtxKey{}).(string)
1819

1920
args := []string{
2021
"pull",
2122
filepath.Join(ociRegistry.Resource.GetHostPort("5000/tcp"), repoName),
23+
fmt.Sprintf("--dir=%s", dir),
2224
}
2325

2426
if ociRegistry.TLSEnabled {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)