Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
corteza
corteza-server
Commits
848e6be3
Commit
848e6be3
authored
4 years ago
by
Denis Arh
Browse files
Options
Download
Email Patches
Plain Diff
Fix actionlog type codegen
parent
6154d369
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
141 additions
and
1 deletion
+141
-1
pkg/actionlog/type_set.gen.go
pkg/actionlog/type_set.gen.go
+33
-1
pkg/actionlog/type_set.gen_test.go
pkg/actionlog/type_set.gen_test.go
+105
-0
pkg/actionlog/types.yaml
pkg/actionlog/types.yaml
+3
-0
No files found.
pkg/actionlog/type
s
.gen.go
→
pkg/actionlog/type
_set
.gen.go
View file @
848e6be3
package
actionlog
// Hello! This file is auto-generated.
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// pkg/actionlog/types.yaml
type
(
...
...
@@ -39,3 +45,29 @@ func (set ActionSet) Filter(f func(*Action) (bool, error)) (out ActionSet, err e
return
}
// FindByID finds items from slice by its ID property
//
// This function is auto-generated.
func
(
set
ActionSet
)
FindByID
(
ID
uint64
)
*
Action
{
for
i
:=
range
set
{
if
set
[
i
]
.
ID
==
ID
{
return
set
[
i
]
}
}
return
nil
}
// IDs returns a slice of uint64s from all items in the set
//
// This function is auto-generated.
func
(
set
ActionSet
)
IDs
()
(
IDs
[]
uint64
)
{
IDs
=
make
([]
uint64
,
len
(
set
))
for
i
:=
range
set
{
IDs
[
i
]
=
set
[
i
]
.
ID
}
return
}
This diff is collapsed.
Click to expand it.
pkg/actionlog/type_set.gen_test.go
0 → 100644
View file @
848e6be3
package
actionlog
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// pkg/actionlog/types.yaml
import
(
"fmt"
"github.com/stretchr/testify/require"
"testing"
)
func
TestActionSetWalk
(
t
*
testing
.
T
)
{
var
(
value
=
make
(
ActionSet
,
3
)
req
=
require
.
New
(
t
)
)
// check walk with no errors
{
err
:=
value
.
Walk
(
func
(
*
Action
)
error
{
return
nil
})
req
.
NoError
(
err
)
}
// check walk with error
req
.
Error
(
value
.
Walk
(
func
(
*
Action
)
error
{
return
fmt
.
Errorf
(
"walk error"
)
}))
}
func
TestActionSetFilter
(
t
*
testing
.
T
)
{
var
(
value
=
make
(
ActionSet
,
3
)
req
=
require
.
New
(
t
)
)
// filter nothing
{
set
,
err
:=
value
.
Filter
(
func
(
*
Action
)
(
bool
,
error
)
{
return
true
,
nil
})
req
.
NoError
(
err
)
req
.
Equal
(
len
(
set
),
len
(
value
))
}
// filter one item
{
found
:=
false
set
,
err
:=
value
.
Filter
(
func
(
*
Action
)
(
bool
,
error
)
{
if
!
found
{
found
=
true
return
found
,
nil
}
return
false
,
nil
})
req
.
NoError
(
err
)
req
.
Len
(
set
,
1
)
}
// filter error
{
_
,
err
:=
value
.
Filter
(
func
(
*
Action
)
(
bool
,
error
)
{
return
false
,
fmt
.
Errorf
(
"filter error"
)
})
req
.
Error
(
err
)
}
}
func
TestActionSetIDs
(
t
*
testing
.
T
)
{
var
(
value
=
make
(
ActionSet
,
3
)
req
=
require
.
New
(
t
)
)
// construct objects
value
[
0
]
=
new
(
Action
)
value
[
1
]
=
new
(
Action
)
value
[
2
]
=
new
(
Action
)
// set ids
value
[
0
]
.
ID
=
1
value
[
1
]
.
ID
=
2
value
[
2
]
.
ID
=
3
// Find existing
{
val
:=
value
.
FindByID
(
2
)
req
.
Equal
(
uint64
(
2
),
val
.
ID
)
}
// Find non-existing
{
val
:=
value
.
FindByID
(
4
)
req
.
Nil
(
val
)
}
// List IDs from set
{
val
:=
value
.
IDs
()
req
.
Equal
(
len
(
val
),
len
(
value
))
}
}
This diff is collapsed.
Click to expand it.
pkg/actionlog/types.yaml
0 → 100644
View file @
848e6be3
package
:
actionlog
types
:
Action
:
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment