Skip to content

Commit

Permalink
test: e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
hosekpeter committed Nov 8, 2024
1 parent 09a3fda commit 5254772
Show file tree
Hide file tree
Showing 125 changed files with 764 additions and 2 deletions.
3 changes: 1 addition & 2 deletions internal/pkg/state/registry/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package registry
import (
"context"
"fmt"
"github.com/stretchr/testify/require"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/keboola/keboola-as-code/internal/pkg/filesystem"
"github.com/keboola/keboola-as-code/internal/pkg/filesystem/aferofs"
Expand Down Expand Up @@ -190,7 +190,6 @@ func TestRegistry_SetIgnoredConfigsOrRows(t *testing.T) {
assert.Len(t, registry.IgnoredConfigs(), 1)
assert.Equal(t, registry.IgnoredConfigRows()[0].ID.String(), "34")
assert.Equal(t, registry.IgnoredConfigs()[0].ID.String(), "345")

}

func TestRegistry_GetPath(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions test/cli/allow-target-env/pull-ignore-configs/args
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pull --storage-api-token %%TEST_KBC_STORAGE_API_TOKEN%%
2 changes: 2 additions & 0 deletions test/cli/allow-target-env/pull-ignore-configs/env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
KBC_PROJECT_ID=%%TEST_KBC_PROJECT_ID%%
KBC_BRANCH_ID=%%TEST_BRANCH_MAIN_ID%%
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
Empty file.
7 changes: 7 additions & 0 deletions test/cli/allow-target-env/pull-ignore-configs/expected-stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Overriding the project ID by the environment variable KBC_PROJECT_ID=%s
Overriding the branch ID by the environment variable KBC_BRANCH_ID=%s
Plan for "pull" operation:
+ C main/app/keboola.data-apps/data-app
+ C main/extractor/keboola.ex-db-mysql/with-rows
+ R main/extractor/keboola.ex-db-mysql/with-rows/rows/test-view
Pull done.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
keboola.ex-db-mysql/%%TEST_BRANCH_MAIN_CONFIG_WITH_ROWS_ID%%/%%TEST_BRANCH_MAIN_CONFIG_WITH_ROWS_ROW_USERS_ID%%
keboola.ex-db-mysql/%%TEST_BRANCH_MAIN_CONFIG_WITH_ROWS_ID%%/%%TEST_BRANCH_MAIN_CONFIG_WITH_ROWS_ROW_DISABLED_ID%%
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"version": 2,
"project": {
"id": 1,
"apiHost": "%%TEST_KBC_STORAGE_API_HOST%%"
},
"allowTargetEnv": true,
"sortBy": "path",
"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": [
"2"
],
"ignoredComponents": [],
"templates": {
"repositories": [
{
"type": "git",
"name": "keboola",
"url": "https://github.com/keboola/keboola-as-code-templates.git",
"ref": "main"
}
]
},
"branches": [
{
"id": 2,
"path": "main"
}
],
"configurations": []
}
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "Main",
"isDefault": true
}
18 changes: 18 additions & 0 deletions test/cli/allow-target-env/pull-ignore-configs/initial-state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"backend": {
"type": "snowflake"
},
"allBranchesConfigs": [ ],
"branches": [
{
"branch": {
"name": "Main",
"isDefault": true
},
"configs": [
"with-rows",
"data-app"
]
}
]
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
keboola.ex-db-mysql/%%TEST_BRANCH_MAIN_CONFIG_WITH_ROWS_ID%%/%%TEST_BRANCH_MAIN_CONFIG_WITH_ROWS_ROW_USERS_ID%%
keboola.ex-db-mysql/%%TEST_BRANCH_MAIN_CONFIG_WITH_ROWS_ID%%/%%TEST_BRANCH_MAIN_CONFIG_WITH_ROWS_ROW_DISABLED_ID%%
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"version": 2,
"project": {
"id": 1,
"apiHost": "%%TEST_KBC_STORAGE_API_HOST%%"
},
"allowTargetEnv": true,
"sortBy": "path",
"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": [
"2"
],
"ignoredComponents": [],
"templates": {
"repositories": [
{
"type": "git",
"name": "keboola",
"url": "https://github.com/keboola/keboola-as-code-templates.git",
"ref": "main"
}
]
},
"branches": [
{
"id": 2,
"path": "main"
}
],
"configurations": [
{
"branchId": 2,
"componentId": "keboola.data-apps",
"id": "%%TEST_BRANCH_MAIN_CONFIG_DATA_APP_ID%%",
"path": "app/keboola.data-apps/data-app",
"rows": []
},
{
"branchId": 2,
"componentId": "keboola.ex-db-mysql",
"id": "%%TEST_BRANCH_MAIN_CONFIG_WITH_ROWS_ID%%",
"path": "extractor/keboola.ex-db-mysql/with-rows",
"rows": [
{
"id": "%%TEST_BRANCH_MAIN_CONFIG_WITH_ROWS_ROW_TEST_VIEW_ID%%",
"path": "rows/test-view"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"backends": [
%A
],
"features": [
%A
],
"defaultBranchId": %A
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"foo": "bar"
}
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": "Data App",
"isDisabled": false
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parameters": {
"db": {
"host": "mysql.example.com"
}
}
}
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": "with-rows",
"isDisabled": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"parameters": {
"incremental": false
}
}
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": "test_view",
"isDisabled": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "Main",
"isDefault": true
}
1 change: 1 addition & 0 deletions test/cli/pull/ignore-configurations/args
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pull --verbose --storage-api-token %%TEST_KBC_STORAGE_API_TOKEN%%
1 change: 1 addition & 0 deletions test/cli/pull/ignore-configurations/expected-code
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
Empty file.
31 changes: 31 additions & 0 deletions test/cli/pull/ignore-configurations/expected-stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
%A
DEBUG Project state has been successfully loaded.
%A
Plan for "pull" operation:
+ B bar
+ C bar/_shared/keboola.python-transformation-v2
+ R bar/_shared/keboola.python-transformation-v2/codes/code-with-variables
+ C bar/_shared/keboola.python-transformation-v2/codes/code-with-variables/variables
+ R bar/_shared/keboola.python-transformation-v2/codes/my-code-1
+ R bar/_shared/keboola.python-transformation-v2/codes/my-code-2
+ C bar/extractor/ex-generic-v2/disabled
+ C bar/extractor/ex-generic-v2/empty
+ C bar/extractor/keboola.ex-db-mysql/with-rows
+ R bar/extractor/keboola.ex-db-mysql/with-rows/rows/disabled
+ R bar/extractor/keboola.ex-db-mysql/with-rows/rows/test-view
+ C bar/transformation/keboola.python-transformation-v2/python-transformation
+ C bar/transformation/keboola.python-transformation-v2/transformation-with-shared-code
+ C bar/transformation/keboola.python-transformation-v2/transformation-with-shared-code/variables
+ R bar/transformation/keboola.python-transformation-v2/transformation-with-shared-code/variables/values/default
+ C bar/transformation/keboola.snowflake-transformation/snowflake-transformation
+ B foo
+ C foo/extractor/ex-generic-v2/empty
+ C foo/extractor/ex-generic-v2/without-rows
+ B main
+ C main/extractor/ex-generic-v2/empty
%A
DEBUG Saved ".keboola/manifest.json"
%A
INFO Pull done.
%A
DEBUG Sent "sync-pull" successful event id: "%s"
Empty file.
3 changes: 3 additions & 0 deletions test/cli/pull/ignore-configurations/in/.keboola/kbc_ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
keboola.data-apps/%%TEST_BRANCH_MAIN_CONFIG_DATA_APP_ID%%
keboola.ex-db-mysql/%%TEST_BRANCH_BAR_CONFIG_WITH_ROWS_ID%%/%%TEST_BRANCH_BAR_CONFIG_WITH_ROWS_ROW_USERS_ID%%
keboola.ex-db-mysql/%%TEST_BRANCH_FOO_CONFIG_WITH_ROWS_ID%%
36 changes: 36 additions & 0 deletions test/cli/pull/ignore-configurations/in/.keboola/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"version": 2,
"project": {
"id": %%TEST_KBC_PROJECT_ID%%,
"apiHost": "%%TEST_KBC_STORAGE_API_HOST%%"
},
"allowTargetEnv": false,
"sortBy": "path",
"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": [
"__all__"
],
"ignoredComponents": [],
"templates": {
"repositories": [
{
"type": "git",
"name": "keboola",
"url": "https://github.com/keboola/keboola-as-code-templates.git",
"ref": "main"
}
]
},
"branches": [],
"configurations": []
}
Empty file.
52 changes: 52 additions & 0 deletions test/cli/pull/ignore-configurations/initial-state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"backend": {
"type": "snowflake"
},
"allBranchesConfigs": [
"empty"
],
"branches": [
{
"branch": {
"name": "Main",
"isDefault": true
},
"configs": [
"data-app"
]
},
{
"branch": {
"name": "foo",
"isDefault": false
},
"configs": [
"with-rows",
"without-rows"
]
},
{
"branch": {
"name": "bar",
"isDefault": false
},
"configs": [
"with-rows",
"python-transformation",
"shared-codes",
"shared-codes-variables",
"transformation-with-shared-code",
"transformation-with-shared-code-variables",
"snowflake-transformation",
"disabled"
]
}
],
"envs": {
"TEST_SHARED_CODE_ID": "%%TEST_BRANCH_BAR_CONFIG_SHARED_CODES_ID%%",
"TEST_SHARED_CODE_ROW_ID": "%%TEST_BRANCH_BAR_CONFIG_SHARED_CODES_ROW_CODE_WITH_VARIABLES_ID%%",
"TEST_SHARED_CODE_VARIABLES_ID": "%%TEST_BRANCH_BAR_CONFIG_SHARED_CODE_VARIABLES_ID%%",
"TEST_TRANSFORMATION_WITH_SHARED_CODE_VARIABLES_ID": "%%TEST_BRANCH_BAR_CONFIG_TRANSFORMATION_WITH_SHARED_CODE_VARIABLES_ID%%",
"TEST_TRANSFORMATION_WITH_SHARED_CODE_VARIABLES_VALUES_ID": "%%TEST_BRANCH_BAR_CONFIG_TRANSFORMATION_WITH_SHARED_CODE_VARIABLES_ROW_DEFAULT_VALUES_ID%%"
}
}
Empty file.
3 changes: 3 additions & 0 deletions test/cli/pull/ignore-configurations/out/.keboola/kbc_ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
keboola.data-apps/%%TEST_BRANCH_MAIN_CONFIG_DATA_APP_ID%%
keboola.ex-db-mysql/%%TEST_BRANCH_BAR_CONFIG_WITH_ROWS_ID%%/%%TEST_BRANCH_BAR_CONFIG_WITH_ROWS_ROW_USERS_ID%%
keboola.ex-db-mysql/%%TEST_BRANCH_FOO_CONFIG_WITH_ROWS_ID%%
Loading

0 comments on commit 5254772

Please sign in to comment.