Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
perxis-go
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
perxis
perxis-go
Commits
7490eb77
Commit
7490eb77
authored
11 months ago
by
Pavel Antonov
Browse files
Options
Downloads
Patches
Plain Diff
Исправлена функция ListFieldsRecursive
parent
54e5808d
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
pkg/schema/field/field.go
+1
-1
1 addition, 1 deletion
pkg/schema/field/field.go
pkg/schema/field/field_test.go
+7
-2
7 additions, 2 deletions
pkg/schema/field/field_test.go
pkg/schema/schema_test.go
+18
-0
18 additions, 0 deletions
pkg/schema/schema_test.go
with
26 additions
and
3 deletions
pkg/schema/field/field.go
+
1
−
1
View file @
7490eb77
...
...
@@ -380,7 +380,7 @@ func (f *Field) ListFields(filter ...FieldFilterFunc) []*Field {
// ListFieldsRecursive возвращает массив всех вложенных полей рекурсивно
func
(
f
*
Field
)
ListFieldsRecursive
(
filter
...
FieldFilterFunc
)
[]
*
Field
{
fields
:=
f
.
ListFields
(
filter
...
)
for
_
,
fld
:=
range
fields
{
for
_
,
fld
:=
range
f
.
ListF
ields
()
{
fields
=
append
(
fields
,
fld
.
ListFieldsRecursive
(
filter
...
)
...
)
}
return
fields
...
...
This diff is collapsed.
Click to expand it.
pkg/schema/field/field_test.go
+
7
−
2
View file @
7490eb77
...
...
@@ -93,17 +93,22 @@ func TestField_ListFieldsRecursive(t *testing.T) {
func
TestField_ListFieldsRecursive_WithFilter
(
t
*
testing
.
T
)
{
sch
:=
Object
(
"
a
"
,
Object
(
"
f1
"
,
Object
(
"b"
,
Object
(
"c"
,
String
()
.
SetSingleLocale
(
true
),
),
),
"f2"
,
Object
(
"b"
,
Object
(
"c"
,
String
()
.
SetSingleLocale
(
true
),
),
)
.
SetSingleLocale
(
true
),
)
sch
.
EnableState
()
fields
:=
sch
.
ListFieldsRecursive
(
func
(
f
*
Field
)
bool
{
return
f
.
SingleLocale
==
true
})
assert
.
Len
(
t
,
fields
,
1
)
assert
.
Len
(
t
,
fields
,
3
)
}
func
TestField_CloneWithState
(
t
*
testing
.
T
)
{
...
...
This diff is collapsed.
Click to expand it.
pkg/schema/schema_test.go
0 → 100644
+
18
−
0
View file @
7490eb77
package
schema
import
(
"testing"
"git.perx.ru/perxis/perxis-go/pkg/schema/field"
"github.com/stretchr/testify/assert"
)
func
TestSchema_Clone
(
t
*
testing
.
T
)
{
f
:=
New
(
"a"
,
field
.
String
())
f
.
ClearState
()
fld
:=
f
.
Clone
(
false
)
assert
.
Nil
(
t
,
fld
.
State
)
f
.
EnableState
()
fld
=
f
.
Clone
(
false
)
assert
.
NotNil
(
t
,
fld
.
State
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment