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
35cc5b22
Commit
35cc5b22
authored
2 years ago
by
ko_oler
Browse files
Options
Downloads
Patches
Plain Diff
добавлены тесты
parent
eebb8025
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
pkg/setup/collection_test.go
+38
-1
38 additions, 1 deletion
pkg/setup/collection_test.go
with
38 additions
and
1 deletion
pkg/setup/collection_test.go
+
38
−
1
View file @
35cc5b22
...
...
@@ -23,6 +23,8 @@ func TestSetup_InstallCollections(t *testing.T) {
collections
[]
*
collections
.
Collection
collectionsCall
func
(
svc
*
mockscollections
.
Collections
)
envsCall
func
(
svc
*
envmocks
.
Environments
)
co
CollectionsOption
force
bool
wantErr
func
(
t
*
testing
.
T
,
err
error
)
}{
{
...
...
@@ -106,6 +108,36 @@ func TestSetup_InstallCollections(t *testing.T) {
wantErr
:
func
(
t
*
testing
.
T
,
err
error
)
{
assert
.
NoError
(
t
,
err
)
},
co
:
UpdateCollectionSchemaMetadata
(),
},
{
name
:
"Fail to update user collection with same id as in extensions collection"
,
collections
:
[]
*
collections
.
Collection
{{
ID
:
"1"
,
SpaceID
:
"sp"
,
EnvID
:
"env"
,
Schema
:
schema
.
New
(
"name"
,
field
.
String
())
.
WithMetadata
(
extension
.
ExtensionMetadataKey
,
"test-extension"
)}},
collectionsCall
:
func
(
svc
*
mockscollections
.
Collections
)
{
svc
.
On
(
"Get"
,
mock
.
Anything
,
"sp"
,
"env"
,
"1"
)
.
Return
(
&
collections
.
Collection
{
ID
:
"1"
,
SpaceID
:
"sp"
,
EnvID
:
"env"
,
Schema
:
schema
.
New
(
"name"
,
field
.
String
())},
nil
)
.
Once
()
},
wantErr
:
func
(
t
*
testing
.
T
,
err
error
)
{
assert
.
Error
(
t
,
err
)
assert
.
ErrorIs
(
t
,
err
,
collections
.
ErrAlreadyExists
)
},
co
:
UpdateCollectionSchemaMetadata
(),
},
{
name
:
"Update user collection with same id as in extensions collection with force"
,
collections
:
[]
*
collections
.
Collection
{{
ID
:
"1"
,
SpaceID
:
"sp"
,
EnvID
:
"env"
,
Schema
:
schema
.
New
(
"name"
,
field
.
String
())
.
WithMetadata
(
extension
.
ExtensionMetadataKey
,
"test-extension"
)}},
collectionsCall
:
func
(
svc
*
mockscollections
.
Collections
)
{
svc
.
On
(
"Get"
,
mock
.
Anything
,
"sp"
,
"env"
,
"1"
)
.
Return
(
&
collections
.
Collection
{
ID
:
"1"
,
SpaceID
:
"sp"
,
EnvID
:
"env"
,
Schema
:
schema
.
New
(
"name"
,
field
.
String
())},
nil
)
.
Once
()
svc
.
On
(
"Update"
,
mock
.
Anything
,
&
collections
.
Collection
{
ID
:
"1"
,
SpaceID
:
"sp"
,
EnvID
:
"env"
,
Schema
:
schema
.
New
(
"name"
,
field
.
String
())
.
WithMetadata
(
extension
.
ExtensionMetadataKey
,
"test-extension"
)})
.
Return
(
nil
)
.
Once
()
svc
.
On
(
"SetSchema"
,
mock
.
Anything
,
"sp"
,
"env"
,
"1"
,
schema
.
New
(
"name"
,
field
.
String
())
.
WithMetadata
(
extension
.
ExtensionMetadataKey
,
"test-extension"
))
.
Return
(
nil
)
.
Once
()
},
envsCall
:
func
(
svc
*
envmocks
.
Environments
)
{
svc
.
On
(
"Migrate"
,
mock
.
Anything
,
"sp"
,
"env"
,
&
environments
.
MigrateOptions
{
Wait
:
true
})
.
Return
(
nil
)
.
Once
()
},
wantErr
:
func
(
t
*
testing
.
T
,
err
error
)
{
assert
.
NoError
(
t
,
err
)
},
co
:
UpdateCollectionSchemaMetadata
(),
force
:
true
,
},
{
name
:
"Update exist view collection with the same id"
,
...
...
@@ -150,7 +182,12 @@ func TestSetup_InstallCollections(t *testing.T) {
}
s
:=
NewSetup
(
&
content
.
Content
{
Collections
:
c
,
Environments
:
e
},
"sp"
,
"env"
,
nil
)
s
.
force
=
tt
.
force
if
tt
.
co
!=
nil
{
s
.
AddCollections
(
tt
.
collections
,
tt
.
co
)
}
else
{
s
.
AddCollections
(
tt
.
collections
)
}
tt
.
wantErr
(
t
,
s
.
InstallCollections
(
context
.
Background
()))
})
}
...
...
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