Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nmaas Janitor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nmaas
nmaas Janitor
Commits
8032200b
Commit
8032200b
authored
6 years ago
by
Michał Bień
Browse files
Options
Downloads
Patches
Plain Diff
janitor tests part 4
parent
70c9eec9
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pkg/service/v1/config-service_test.go
+47
-2
47 additions, 2 deletions
pkg/service/v1/config-service_test.go
with
47 additions
and
2 deletions
pkg/service/v1/config-service_test.go
+
47
−
2
View file @
8032200b
...
...
@@ -58,15 +58,26 @@ func TestReadinessServiceServer_CheckIfReady(t *testing.T) {
t
.
Fail
()
}
//create mock deployment
//create mock deployment
that is fully deployed
depl
:=
extension
.
Deployment
{}
depl
.
Name
=
"test-uid"
q
:=
int32
(
5
)
depl
.
Spec
.
Replicas
=
&
q
depl
.
Status
.
Replicas
=
q
depl
.
Status
.
Ready
Replicas
=
q
_
,
_
=
client
.
ExtensionsV1beta1
()
.
Deployments
(
"test-namespace"
)
.
Create
(
&
depl
)
res
,
err
=
server
.
CheckIfReady
(
context
.
Background
(),
&
req
)
if
err
!=
nil
||
res
.
Status
!=
v1
.
Status_OK
{
t
.
Fail
()
}
//modify mock deployment to be partially deployed
p
:=
int32
(
3
)
depl
.
Status
.
ReadyReplicas
=
p
_
,
_
=
client
.
ExtensionsV1beta1
()
.
Deployments
(
"test-namespace"
)
.
Update
(
&
depl
)
if
err
!=
nil
||
res
.
Status
!=
v1
.
Status_PENDING
{
t
.
Fail
()
}
}
func
TestCertManagerServiceServer_DeleteIfExists
(
t
*
testing
.
T
)
{
...
...
@@ -96,6 +107,14 @@ func TestCertManagerServiceServer_DeleteIfExists(t *testing.T) {
if
err
!=
nil
||
res
.
Status
!=
v1
.
Status_OK
{
t
.
Fail
()
}
//Create mock secret
sec
:=
corev1
.
Secret
{}
sec
.
Name
=
"test-uid-tls"
_
,
_
=
client
.
CoreV1
()
.
Secrets
(
"test-namespace"
)
.
Create
(
&
sec
)
//Pass
res
,
err
=
server
.
DeleteIfExists
(
context
.
Background
(),
&
req
)
}
func
TestBasicAuthServiceServer_DeleteIfExists
(
t
*
testing
.
T
)
{
...
...
@@ -106,4 +125,30 @@ func TestBasicAuthServiceServer_DeleteIfExists(t *testing.T) {
if
err
==
nil
||
res
!=
nil
{
t
.
Fail
()
}
//Fail on namespace check
freq
:=
v1
.
InstanceRequest
{
Api
:
apiVersion
,
Deployment
:&
fake_ns_inst
}
res
,
err
=
server
.
DeleteIfExists
(
context
.
Background
(),
&
freq
)
if
err
==
nil
||
res
.
Status
!=
v1
.
Status_FAILED
{
t
.
Fail
()
}
//create mock namespace
ns
:=
corev1
.
Namespace
{}
ns
.
Name
=
"test-namespace"
_
,
_
=
client
.
CoreV1
()
.
Namespaces
()
.
Create
(
&
ns
)
//Pass if already nonexistent
res
,
err
=
server
.
DeleteIfExists
(
context
.
Background
(),
&
req
)
if
err
!=
nil
||
res
.
Status
!=
v1
.
Status_OK
{
t
.
Fail
()
}
//Create mock secret
sec
:=
corev1
.
Secret
{}
sec
.
Name
=
getAuthSecretName
(
"test-uid"
)
_
,
_
=
client
.
CoreV1
()
.
Secrets
(
"test-namespace"
)
.
Create
(
&
sec
)
//Pass
res
,
err
=
server
.
DeleteIfExists
(
context
.
Background
(),
&
req
)
}
\ No newline at end of file
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