diff --git a/Makefile b/Makefile index afe6ebc43..f939bc29d 100644 --- a/Makefile +++ b/Makefile @@ -198,10 +198,8 @@ test.store: $(GOTEST) $(GOTEST) $(TEST_FLAGS) $(TEST_SUITE_store) # Runs ALL tests -test.all: - @echo "pass" -#test.all: $(GOTEST) -# $(GOTEST) $(TEST_FLAGS) $(TEST_SUITE_all) +test.all: $(GOTEST) + $(GOTEST) $(TEST_FLAGS) $(TEST_SUITE_all) # Unit testing testing, system or compose test.unit.%: $(GOTEST) diff --git a/pkg/dal/service.go b/pkg/dal/service.go index 7c990d305..83f872a65 100644 --- a/pkg/dal/service.go +++ b/pkg/dal/service.go @@ -635,10 +635,7 @@ func (svc *service) ReplaceModel(ctx context.Context, model *Model) (err error) defer svc.updateIssues(issues) if model.ConnectionID == 0 { - // model w/o connection: - // add model issue and carry on - issues.addModelIssue(model.ResourceID, errConnectionNotFound(model.ConnectionID)) - return nil + model.ConnectionID = svc.defConnID } // Check if update diff --git a/system/types/dal_connection.go b/system/types/dal_connection.go index 97fbdaa42..8c63c403b 100644 --- a/system/types/dal_connection.go +++ b/system/types/dal_connection.go @@ -82,7 +82,7 @@ type ( // type of connection Type string `json:"type"` - // parameters for th connection + // parameters for the connection Params map[string]any `json:"params"` // ident to be used when generating models from modules using this connection diff --git a/tests/dal/dal_crud_connection_test.go b/tests/dal/dal_crud_connection_test.go index 4a2730f7d..d4b40a1a0 100644 --- a/tests/dal/dal_crud_connection_test.go +++ b/tests/dal/dal_crud_connection_test.go @@ -114,6 +114,7 @@ func Test_dal_crud_connection_update(t *testing.T) { }) helpers.AllowMe(h, types.DalConnectionRbacResource(0), "update") + helpers.AllowMe(h, types.DalConnectionRbacResource(0), "dal-config.manage") h.apiInit(). Put(fmt.Sprintf("/system/dal/connections/%d", sl.ID)). diff --git a/tests/dal/dal_utils_test.go b/tests/dal/dal_utils_test.go index bfeaeeb79..d82d888a6 100644 --- a/tests/dal/dal_utils_test.go +++ b/tests/dal/dal_utils_test.go @@ -24,7 +24,7 @@ type ( driver struct { name string dsn string - setup func(ctx context.Context, t aaaa, dsn string) + setup func(ctx context.Context, t wrapTest, dsn string) } dalService interface { @@ -72,7 +72,7 @@ type ( } } - aaaa interface { + wrapTest interface { require.TestingT Name() string } @@ -153,7 +153,12 @@ func initSvc(ctx context.Context, d driver) (dalService, error) { dal.MakeConnection( c.ID, nil, - dal.ConnectionParams{}, + dal.ConnectionParams{ + Type: "corteza::dal:connection:dsn", + Params: map[string]any{ + "dsn": d.dsn, + }, + }, cm, ), true, @@ -284,7 +289,7 @@ func collectDrivers() []driver { { name: "mysql", dsn: os.Getenv("DAL_TEST_DSN_MYSQL"), - setup: func(ctx context.Context, t aaaa, dsn string) { + setup: func(ctx context.Context, t wrapTest, dsn string) { conn, err := mysql.Setup(ctx, dsn) require.NoError(t, err) diff --git a/tests/dal/main_test.go b/tests/dal/main_test.go index bcd41b7a5..492abc9f9 100644 --- a/tests/dal/main_test.go +++ b/tests/dal/main_test.go @@ -416,7 +416,7 @@ func rs(a ...int) string { return string(rand.Bytes(l)) } -func loadScenarioSources(t aaaa, driver, ext string) (src string) { +func loadScenarioSources(t wrapTest, driver, ext string) (src string) { scenarioName := t.Name()[5:] src = loadScenarioSource(t, "generic", fmt.Sprintf("_.%s", ext)) @@ -430,7 +430,7 @@ func loadScenarioSources(t aaaa, driver, ext string) (src string) { return } -func loadScenarioSource(t aaaa, scenarioName, srcName string) (src string) { +func loadScenarioSource(t wrapTest, scenarioName, srcName string) (src string) { f, err := os.Open(path.Join("testdata", scenarioName, srcName)) if err != nil && os.IsNotExist(err) { return "" diff --git a/tests/dal/testdata/generic/nok_connection_connectivity.json b/tests/dal/testdata/generic/nok_connection_connectivity.json index f9182cd93..73ec864a9 100644 --- a/tests/dal/testdata/generic/nok_connection_connectivity.json +++ b/tests/dal/testdata/generic/nok_connection_connectivity.json @@ -17,7 +17,9 @@ }, "config": { - "connection": { + "dal": { + "modelIdent": "compose_record", + "type": "corteza::dal:connection:dsn", "params": { "dsn": "NO" @@ -25,24 +27,6 @@ }, "privacy": { "sensitivityLevelID": "0" - }, - "dal": { - "properties": {}, - "operations": [ - "corteza::dal:operation:create", - "corteza::dal:operation:update", - "corteza::dal:operation:search", - "corteza::dal:operation:lookup", - "corteza::dal:operation:paging", - "corteza::dal:operation:stats", - "corteza::dal:operation:sorting", - "corteza::dal:operation:RBAC" - ], - - "modelIdent": "compose_record", - "attributeIdent": "values", - "partitionFormat": "compose_record_{{namespace}}_{{module}}", - "partitionIdentValidator": "" } } } diff --git a/tests/dal/testdata/generic/nok_connection_invalid_type.json b/tests/dal/testdata/generic/nok_connection_invalid_type.json index a4f08e3c7..d733e6f8a 100644 --- a/tests/dal/testdata/generic/nok_connection_invalid_type.json +++ b/tests/dal/testdata/generic/nok_connection_invalid_type.json @@ -17,7 +17,9 @@ }, "config": { - "connection": { + "dal": { + "modelIdent": "compose_record", + "type": "corteza::dal:connection:dsn", "params": { "dsn": "sqlite3://file::memory:?cache=shared&mode=memory" @@ -25,24 +27,6 @@ }, "privacy": { "sensitivityLevelID": "0" - }, - "dal": { - "properties": {}, - "operations": [ - "corteza::dal:operation:create", - "corteza::dal:operation:update", - "corteza::dal:operation:search", - "corteza::dal:operation:lookup", - "corteza::dal:operation:paging", - "corteza::dal:operation:stats", - "corteza::dal:operation:sorting", - "corteza::dal:operation:RBAC" - ], - - "modelIdent": "compose_record", - "attributeIdent": "values", - "partitionFormat": "compose_record_{{namespace}}_{{module}}", - "partitionIdentValidator": "" } } } diff --git a/tests/dal/testdata/generic/nok_connection_sensitivity.json b/tests/dal/testdata/generic/nok_connection_sensitivity.json index 0ef373f6a..9556b8de6 100644 --- a/tests/dal/testdata/generic/nok_connection_sensitivity.json +++ b/tests/dal/testdata/generic/nok_connection_sensitivity.json @@ -17,7 +17,9 @@ }, "config": { - "connection": { + "dal": { + "modelIdent": "compose_record", + "type": "corteza::dal:connection:dsn", "params": { "dsn": "sqlite3://file::memory:?cache=shared&mode=memory" @@ -25,24 +27,6 @@ }, "privacy": { "sensitivityLevelID": "42" - }, - "dal": { - "properties": {}, - "operations": [ - "corteza::dal:operation:create", - "corteza::dal:operation:update", - "corteza::dal:operation:search", - "corteza::dal:operation:lookup", - "corteza::dal:operation:paging", - "corteza::dal:operation:stats", - "corteza::dal:operation:sorting", - "corteza::dal:operation:RBAC" - ], - - "modelIdent": "compose_record", - "attributeIdent": "values", - "partitionFormat": "compose_record_{{namespace}}_{{module}}", - "partitionIdentValidator": "" } } } diff --git a/tests/dal/testdata/generic/ok_connection.json b/tests/dal/testdata/generic/ok_connection.json index b819598e9..f12ec194b 100644 --- a/tests/dal/testdata/generic/ok_connection.json +++ b/tests/dal/testdata/generic/ok_connection.json @@ -17,7 +17,9 @@ }, "config": { - "connection": { + "dal": { + "modelIdent": "compose_record", + "type": "corteza::dal:connection:dsn", "params": { "dsn": "sqlite3://file::memory:?cache=shared&mode=memory" @@ -25,24 +27,6 @@ }, "privacy": { "sensitivityLevelID": "0" - }, - "dal": { - "properties": {}, - "operations": [ - "corteza::dal:operation:create", - "corteza::dal:operation:update", - "corteza::dal:operation:search", - "corteza::dal:operation:lookup", - "corteza::dal:operation:paging", - "corteza::dal:operation:stats", - "corteza::dal:operation:sorting", - "corteza::dal:operation:RBAC" - ], - - "modelIdent": "compose_record", - "attributeIdent": "values", - "partitionFormat": "compose_record_{{namespace}}_{{module}}", - "partitionIdentValidator": "" } } } diff --git a/tests/dal/testdata/generic/ok_connection_update.json b/tests/dal/testdata/generic/ok_connection_update.json index 7c1db2212..21de6db1e 100644 --- a/tests/dal/testdata/generic/ok_connection_update.json +++ b/tests/dal/testdata/generic/ok_connection_update.json @@ -17,7 +17,9 @@ }, "config": { - "connection": { + "dal": { + "modelIdent": "compose_record", + "type": "corteza::dal:connection:dsn", "params": { "dsn": "sqlite3://file::memory:?cache=shared&mode=memory" @@ -25,24 +27,6 @@ }, "privacy": { "sensitivityLevelID": "0" - }, - "dal": { - "properties": {}, - "operations": [ - "corteza::dal:operation:create", - "corteza::dal:operation:update", - "corteza::dal:operation:search", - "corteza::dal:operation:lookup", - "corteza::dal:operation:paging", - "corteza::dal:operation:stats", - "corteza::dal:operation:sorting", - "corteza::dal:operation:RBAC" - ], - - "modelIdent": "compose_record", - "attributeIdent": "values", - "partitionFormat": "compose_record_{{namespace}}_{{module}}", - "partitionIdentValidator": "" } } }