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
9ce2fdf2
Commit
9ce2fdf2
authored
1 year ago
by
ko_oler
Browse files
Options
Downloads
Patches
Plain Diff
fix
parent
3b0ba354
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
pkg/spaces/service_test.go
+13
-42
13 additions, 42 deletions
pkg/spaces/service_test.go
with
13 additions
and
42 deletions
pkg/spaces/service_test.go
+
13
−
42
View file @
9ce2fdf2
...
...
@@ -5,75 +5,46 @@ import (
"testing"
)
type
testSpaces
struct
{
// dummySpaces используется для имитации поведения Spaces
// Моки использовать не можем, так как получается циклический импорт
type
dummySpaces
struct
{
Spaces
space
*
Space
}
func
(
t
*
test
Spaces
)
Get
(
_
context
.
Context
,
spaceID
string
)
(
*
Space
,
error
)
{
return
t
.
space
,
nil
}
func
(
t
*
dummy
Spaces
)
Get
(
_
context
.
Context
,
_
string
)
(
*
Space
,
error
)
{
return
t
.
space
,
nil
}
func
TestIsSpaceAvailable
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
name
string
spacesCall
*
testSpaces
spaceId
string
space
*
Space
wantErr
bool
}{
{
"Without StateInfo"
,
&
testSpaces
{
space
:
&
Space
{
ID
:
"space"
,
OrgID
:
"org"
,
Name
:
"test-space"
,
},
},
"space"
,
&
Space
{
ID
:
"space"
,
OrgID
:
"org"
,
Name
:
"test-space"
},
false
,
},
{
"StateReady"
,
&
testSpaces
{
space
:
&
Space
{
ID
:
"space"
,
OrgID
:
"org"
,
Name
:
"test-space"
,
StateInfo
:
&
StateInfo
{
State
:
StateReady
},
},
},
"space"
,
&
Space
{
ID
:
"space"
,
OrgID
:
"org"
,
Name
:
"test-space"
,
StateInfo
:
&
StateInfo
{
State
:
StateReady
}},
false
,
},
{
"StatePreparing"
,
&
testSpaces
{
space
:
&
Space
{
ID
:
"space"
,
OrgID
:
"org"
,
Name
:
"test-space"
,
StateInfo
:
&
StateInfo
{
State
:
StatePreparing
},
},
},
"space"
,
&
Space
{
ID
:
"space"
,
OrgID
:
"org"
,
Name
:
"test-space"
,
StateInfo
:
&
StateInfo
{
State
:
StatePreparing
}},
true
,
},
{
"StateMigration"
,
&
testSpaces
{
space
:
&
Space
{
ID
:
"space"
,
OrgID
:
"org"
,
Name
:
"test-space"
,
StateInfo
:
&
StateInfo
{
State
:
StateMigration
},
},
},
"space"
,
&
Space
{
ID
:
"space"
,
OrgID
:
"org"
,
Name
:
"test-space"
,
StateInfo
:
&
StateInfo
{
State
:
StateMigration
}},
true
,
},
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
if
err
:=
IsSpaceAvailable
(
context
.
Background
(),
tt
.
spacesCall
,
tt
.
spaceId
);
(
err
!=
nil
)
!=
tt
.
wantErr
{
spaces
:=
&
dummySpaces
{
space
:
tt
.
space
}
if
err
:=
IsSpaceAvailable
(
context
.
Background
(),
spaces
,
"space"
);
(
err
!=
nil
)
!=
tt
.
wantErr
{
t
.
Errorf
(
"IsSpaceAvailable() error = %v, wantErr %v"
,
err
,
tt
.
wantErr
)
}
})
...
...
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