Skip to content

Commit

Permalink
Merge pull request #2183 from keboola/petr-hosek-PSGO-898_run_test
Browse files Browse the repository at this point in the history
Don't test deprecated templates
  • Loading branch information
hosekpeter authored Jan 6, 2025
2 parents dd9c9b0 + 9da82fb commit dee70fd
Show file tree
Hide file tree
Showing 33 changed files with 322 additions and 8 deletions.
20 changes: 12 additions & 8 deletions internal/pkg/service/cli/cmd/template/test/run/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ func Command(p dependencies.Provider) *cobra.Command {
return err
}

// Options
options := testOp.Options{
LocalOnly: f.LocalOnly,
RemoteOnly: f.RemoteOnly,
TestName: f.TestName,
Verbose: f.Verbose,
}

// Get dependencies
d, err := p.LocalCommandScope(cmd.Context(), f.StorageAPIHost, dependencies.WithDefaultStorageAPIHost())
if err != nil {
Expand Down Expand Up @@ -71,6 +63,10 @@ func Command(p dependencies.Provider) *cobra.Command {
templates = append(templates, tmpl)
} else {
for _, t := range repo.Templates() {
// Don't test deprecated templates
if t.Deprecated {
continue
}
v, err := t.DefaultVersionOrErr()
if err != nil {
return errors.Errorf(`loading default version for template "%s" failed: %w`, t.ID, err)
Expand All @@ -83,6 +79,14 @@ func Command(p dependencies.Provider) *cobra.Command {
}
}

// Options
options := testOp.Options{
LocalOnly: f.LocalOnly,
RemoteOnly: f.RemoteOnly,
TestName: f.TestName,
Verbose: f.Verbose,
}

// Test templates
errs := errors.NewMultiError()
for _, tmpl := range templates {
Expand Down
16 changes: 16 additions & 0 deletions test/cli/template-test-run/local-all/in/.keboola/repository.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@
"path": "v2"
}
]
},
{
"id": "template-3",
"name": "My Template 3",
"deprecated": true,
"description": "Full workflow to ...",
"versions": [
{
"version": "2.0.0",
"description": "notes",
"stable": false,
"components": [
"keboola.ex-facebook"
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### My Template

Full workflow to ...

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# My Template

## Extended description
- of a template for demo purposes
- from the examples in the API documentation

## Some Example
```
with.a.code()
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
parameters: {
api: {
baseUrl: Input("ex-generic-v2-api-base-url"),
},
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test fixture
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
name: "empty",
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
stepsGroups: [
{
description: "Default Group",
required: "all",
steps: [
{
icon: "common:settings",
name: "Default Step",
description: "Default Step",
inputs: [
{
id: "ex-generic-v2-api-base-url",
name: "Api BaseUrl",
description: "a",
type: "string",
kind: "input",
default: "https://jsonplaceholder.typicode.com",
},
],
},
],
},
],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
configurations: [
{
componentId: "ex-generic-v2",
id: ConfigId("empty"),
path: "extractor/ex-generic-v2/empty",
rows: [],
},
],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"version": 2,
"project": {
"id": __PROJECT_ID__,
"apiHost": "__STORAGE_API_HOST__"
},
"allowTargetEnv": false,
"sortBy": "id",
"naming": {
"branch": "{branch_name}",
"config": "{component_type}/{component_id}/{config_name}",
"configRow": "rows/{config_row_name}",
"schedulerConfig": "schedules/{config_name}",
"sharedCodeConfig": "_shared/{target_component_id}",
"sharedCodeConfigRow": "codes/{config_row_name}",
"variablesConfig": "variables",
"variablesValuesRow": "values/{config_row_name}",
"dataAppConfig": "app/{component_id}/{config_name}"
},
"allowedBranches": [
"*"
],
"ignoredComponents": [],
"templates": {
"repositories": [
{
"type": "dir",
"name": "keboola",
"url": "../repository",
"ref": "main"
}
]
},
"branches": [
{
"id": 1,
"path": "main",
"metadata": {
"KBC.KAC.templates.instances": "[{\"instanceId\":\"%s\",\"instanceName\":\"test\",\"templateId\":\"template-2\",\"repositoryName\":\"keboola\",\"version\":\"2.0.0\",\"created\":{\"date\":\"%s\",\"tokenId\":\"%s\"},\"updated\":{\"date\":\"%s\",\"tokenId\":\"%s\"}}]"
}
}
],
"configurations": [
{
"branchId": 1,
"componentId": "ex-generic-v2",
"id": "%s",
"path": "extractor/ex-generic-v2/empty",
"metadata": {
"KBC.KAC.templates.configId": "{\"idInTemplate\":\"empty\"}",
"KBC.KAC.templates.configInputs": "[{\"input\":\"ex-generic-v2-api-base-url\",\"key\":\"parameters.api.baseUrl\"}]",
"KBC.KAC.templates.instanceId": "%s",
"KBC.KAC.templates.repository": "keboola",
"KBC.KAC.templates.templateId": "template-2"
},
"rows": []
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parameters": {
"api": {
"baseUrl": "base/url"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test fixture
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "empty",
"isDisabled": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "Main",
"isDefault": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ex-generic-v2-api-base-url": "base/url"
}
16 changes: 16 additions & 0 deletions test/cli/template-test-run/local-all/out/.keboola/repository.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@
"path": "v2"
}
]
},
{
"id": "template-3",
"name": "My Template 3",
"deprecated": true,
"description": "Full workflow to ...",
"versions": [
{
"version": "2.0.0",
"description": "notes",
"stable": false,
"components": [
"keboola.ex-facebook"
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### My Template

Full workflow to ...

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# My Template

## Extended description
- of a template for demo purposes
- from the examples in the API documentation

## Some Example
```
with.a.code()
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
parameters: {
api: {
baseUrl: Input("ex-generic-v2-api-base-url"),
},
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test fixture
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
name: "empty",
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
stepsGroups: [
{
description: "Default Group",
required: "all",
steps: [
{
icon: "common:settings",
name: "Default Step",
description: "Default Step",
inputs: [
{
id: "ex-generic-v2-api-base-url",
name: "Api BaseUrl",
description: "a",
type: "string",
kind: "input",
default: "https://jsonplaceholder.typicode.com",
},
],
},
],
},
],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
configurations: [
{
componentId: "ex-generic-v2",
id: ConfigId("empty"),
path: "extractor/ex-generic-v2/empty",
rows: [],
},
],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"version": 2,
"project": {
"id": __PROJECT_ID__,
"apiHost": "__STORAGE_API_HOST__"
},
"allowTargetEnv": false,
"sortBy": "id",
"naming": {
"branch": "{branch_name}",
"config": "{component_type}/{component_id}/{config_name}",
"configRow": "rows/{config_row_name}",
"schedulerConfig": "schedules/{config_name}",
"sharedCodeConfig": "_shared/{target_component_id}",
"sharedCodeConfigRow": "codes/{config_row_name}",
"variablesConfig": "variables",
"variablesValuesRow": "values/{config_row_name}",
"dataAppConfig": "app/{component_id}/{config_name}"
},
"allowedBranches": [
"*"
],
"ignoredComponents": [],
"templates": {
"repositories": [
{
"type": "dir",
"name": "keboola",
"url": "../repository",
"ref": "main"
}
]
},
"branches": [
{
"id": 1,
"path": "main",
"metadata": {
"KBC.KAC.templates.instances": "[{\"instanceId\":\"%s\",\"instanceName\":\"test\",\"templateId\":\"template-2\",\"repositoryName\":\"keboola\",\"version\":\"2.0.0\",\"created\":{\"date\":\"%s\",\"tokenId\":\"%s\"},\"updated\":{\"date\":\"%s\",\"tokenId\":\"%s\"}}]"
}
}
],
"configurations": [
{
"branchId": 1,
"componentId": "ex-generic-v2",
"id": "%s",
"path": "extractor/ex-generic-v2/empty",
"metadata": {
"KBC.KAC.templates.configId": "{\"idInTemplate\":\"empty\"}",
"KBC.KAC.templates.configInputs": "[{\"input\":\"ex-generic-v2-api-base-url\",\"key\":\"parameters.api.baseUrl\"}]",
"KBC.KAC.templates.instanceId": "%s",
"KBC.KAC.templates.repository": "keboola",
"KBC.KAC.templates.templateId": "template-2"
},
"rows": []
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parameters": {
"api": {
"baseUrl": "base/url"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test fixture
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "empty",
"isDisabled": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "Main",
"isDefault": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ex-generic-v2-api-base-url": "base/url"
}

0 comments on commit dee70fd

Please sign in to comment.