Skip to content
Snippets Groups Projects
Commit 461c77f2 authored by Pavel Antonov's avatar Pavel Antonov :asterisk:
Browse files

Merge branch 'feature/PRXS-1695-EqualSchemas' into 'master'

Исправлена ошибка, из-за которой схемы коллекций "Настройки/Действия","Настройки/Расширения" при обновлении считались измененными

See merge request perxis/perxis-go!107
parents 9042eebe 9774aee0
No related branches found
No related tags found
No related merge requests found
......@@ -68,7 +68,7 @@ type Extension interface {
}
func CheckInstalled(ctx context.Context, content *content.Content, spaceID, envID, extension string) (bool, error) {
status, err := NewStorage(content).GetExtension(ctx, spaceID, envID, extension)
status, err := NewStorage(content, nil).GetExtension(ctx, spaceID, envID, extension)
if err != nil {
return false, err
}
......
......@@ -74,9 +74,9 @@ func NewActionsCollection(spaceID, envID string) *collections.Collection {
// UI
sch.Field.UI.ListView = &field.View{Options: map[string]interface{}{
"fields": []string{"name", "action", "kind", "target", "updated_at", "updated_by"},
"sort": []string{"name"},
"page_size": 50,
"fields": []interface{}{"name", "action", "kind", "target", "updated_at", "updated_by"},
"sort": []interface{}{"name"},
"page_size": float64(50),
}}
sch.Field.UI.Options["title"] = "name"
......@@ -130,9 +130,9 @@ func NewExtensionsCollection(spaceID, envID string) *collections.Collection {
//UI
sch.Field.UI.ListView = &field.View{Options: map[string]interface{}{
"fields": []string{"id", "title", "updated_at", "updated_by"},
"sort": []string{"title"},
"page_size": 50,
"fields": []interface{}{"id", "title", "updated_at", "updated_by"},
"sort": []interface{}{"title"},
"page_size": float64(50),
}}
sch.Field.UI.Options["title"] = "title"
......
package extension
import (
"encoding/json"
"reflect"
"testing"
"git.perx.ru/perxis/perxis-go/pkg/collections"
"git.perx.ru/perxis/perxis-go/pkg/schema"
"git.perx.ru/perxis/perxis-go/pkg/schema/validate"
"github.com/stretchr/testify/require"
)
func Test_getEnumOpt(t *testing.T) {
......@@ -32,3 +36,17 @@ func Test_getEnumOpt(t *testing.T) {
})
}
}
func TestEqualSchema(t *testing.T) {
for _, collection := range []*collections.Collection{
NewActionsCollection("", ""),
NewExtensionsCollection("", ""),
} {
s1 := collection.Schema
b, err := s1.MarshalJSON()
require.NoError(t, err)
s2 := schema.New()
err = json.Unmarshal(b, s2)
require.Equal(t, s1.Field, s2.Field)
}
}
......@@ -10,6 +10,7 @@ import (
"git.perx.ru/perxis/perxis-go/pkg/errors"
"git.perx.ru/perxis/perxis-go/pkg/setup"
pb "git.perx.ru/perxis/perxis-go/proto/extensions"
"go.uber.org/zap"
"git.perx.ru/perxis/perxis-go/pkg/content"
"git.perx.ru/perxis/perxis-go/pkg/items"
......@@ -29,10 +30,14 @@ type Storage interface {
type storage struct {
content *content.Content
logger *zap.Logger
}
func NewStorage(content *content.Content) Storage {
return &storage{content: content}
func NewStorage(content *content.Content, logger *zap.Logger) Storage {
if logger == nil {
logger = zap.NewNop()
}
return &storage{content: content, logger: logger}
}
func infoFromItem(extension string, item *items.Item) *Info {
......@@ -137,7 +142,7 @@ func (s *storage) DeleteExtension(ctx context.Context, spaceID, envID string, ex
func (s *storage) init(ctx context.Context, spaceID, envID string) error {
// миграция окружения не должна запуститься, поскольку окружение может быть сломано
// расширениями - нужно дать возможность восстановиться
stp := setup.NewSetup(s.content, spaceID, envID, nil).AddCollections([]*collections.Collection{
stp := setup.NewSetup(s.content, spaceID, envID, s.logger).AddCollections([]*collections.Collection{
NewExtensionsCollection(spaceID, envID),
NewActionsCollection(spaceID, envID),
}, setup.SkipMigration())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment