3
0

Fix DAL CRUD tests

This commit is contained in:
Tomaž Jerman
2022-08-02 09:07:17 +02:00
committed by Denis Arh
parent c31f706e95
commit 4f46426c5f
4 changed files with 23 additions and 19 deletions

View File

@@ -3,12 +3,13 @@ package service
import (
"context"
"fmt"
"github.com/cortezaproject/corteza-server/pkg/revisions"
"reflect"
"sort"
"strconv"
"strings"
"github.com/cortezaproject/corteza-server/pkg/revisions"
"github.com/cortezaproject/corteza-server/pkg/dal"
"github.com/cortezaproject/corteza-server/pkg/dal/capabilities"
"github.com/cortezaproject/corteza-server/pkg/filter"
@@ -301,13 +302,13 @@ func (svc module) procDal(m *types.Module) {
ii := svc.dal.SearchModelIssues(m.Config.DAL.ConnectionID, m.ID)
if len(ii) == 0 {
m.Config.DAL.Issues = nil
m.Issues = nil
return
}
m.Config.DAL.Issues = make([]string, len(ii))
m.Issues = make([]string, len(ii))
for i, err := range ii {
m.Config.DAL.Issues[i] = err.Error()
m.Issues[i] = err.Error()
}
}

View File

@@ -3,10 +3,11 @@ package types
import (
"database/sql/driver"
"encoding/json"
"time"
discovery "github.com/cortezaproject/corteza-server/discovery/types"
"github.com/cortezaproject/corteza-server/pkg/sql"
"github.com/jmoiron/sqlx/types"
"time"
"github.com/cortezaproject/corteza-server/pkg/dal"
"github.com/cortezaproject/corteza-server/pkg/dal/capabilities"
@@ -33,6 +34,8 @@ type (
Labels map[string]string `json:"labels,omitempty"`
Issues []string `json:"issues,omitempty"`
NamespaceID uint64 `json:"namespaceID,string"`
CreatedAt time.Time `json:"createdAt,omitempty"`
@@ -82,8 +85,6 @@ type (
ConnectionID uint64 `json:"connectionID,string"`
Capabilities capabilities.Set `json:"capabilities"`
Issues []string `json:"issues,omitempty"`
Constraints map[string][]any `json:"constraints"`
Partitioned bool `json:"partitioned"`
@@ -139,7 +140,7 @@ func (m Module) Clone() *Module {
}
func (m Module) HasIssues() bool {
return len(m.Config.DAL.Issues) > 0
return len(m.Issues) > 0
}
// We won't worry about fields at this point

View File

@@ -27,7 +27,7 @@ func Test_dal_crud_issues_compose_module_missing_sensitivity(t *testing.T) {
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.response.moduleID")).
Assert(jsonpath.Len("$.response.config.dal.issues", 1)).
Assert(jsonpath.Len("$.response.issues", 1)).
End()
dd := json.NewDecoder(rsp.Response.Body)
@@ -42,7 +42,7 @@ func Test_dal_crud_issues_compose_module_missing_sensitivity(t *testing.T) {
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.response.moduleID")).
Assert(jsonpath.NotPresent("$.response.config.dal.issues")).
Assert(jsonpath.NotPresent("$.response.issues")).
End()
rsp = h.apiInit().
@@ -54,7 +54,7 @@ func Test_dal_crud_issues_compose_module_missing_sensitivity(t *testing.T) {
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.response.moduleID")).
Assert(jsonpath.Len("$.response.config.dal.issues", 1)).
Assert(jsonpath.Len("$.response.issues", 1)).
End()
rsp = h.apiInit().
@@ -84,7 +84,7 @@ func Test_dal_crud_issues_compose_module_field_missing_sensitivity(t *testing.T)
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.response.moduleID")).
Assert(jsonpath.Len("$.response.config.dal.issues", 1)).
Assert(jsonpath.Len("$.response.issues", 1)).
End()
dd := json.NewDecoder(rsp.Response.Body)
@@ -98,7 +98,7 @@ func Test_dal_crud_issues_compose_module_field_missing_sensitivity(t *testing.T)
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.response.moduleID")).
Assert(jsonpath.NotPresent("$.response.config.dal.issues")).
Assert(jsonpath.NotPresent("$.response.issues")).
End()
rsp = h.apiInit().
@@ -110,7 +110,7 @@ func Test_dal_crud_issues_compose_module_field_missing_sensitivity(t *testing.T)
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.response.moduleID")).
Assert(jsonpath.Len("$.response.config.dal.issues", 1)).
Assert(jsonpath.Len("$.response.issues", 1)).
End()
rsp = h.apiInit().
@@ -143,7 +143,7 @@ func Test_dal_crud_issues_compose_module_nok_connection(t *testing.T) {
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.response.moduleID")).
Assert(jsonpath.Len("$.response.config.dal.issues", 1)).
Assert(jsonpath.Len("$.response.issues", 1)).
End()
dd := json.NewDecoder(rsp.Response.Body)
@@ -170,7 +170,7 @@ func Test_dal_crud_issues_compose_module_nok_connection(t *testing.T) {
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.response.moduleID")).
Assert(jsonpath.NotPresent("$.response.config.dal.issues")).
Assert(jsonpath.NotPresent("$.response.issues")).
End()
rsp = h.apiInit().

View File

@@ -19,9 +19,11 @@
"name": "name",
"kind": "String",
"privacy": {
"sensitivityLevel": "42",
"usageDisclosure": "A"
"config": {
"privacy": {
"sensitivityLevel": "42",
"usageDisclosure": "A"
}
}
},
{