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
bd6235f9
Commit
bd6235f9
authored
6 years ago
by
Michał Bień
Browse files
Options
Downloads
Patches
Plain Diff
janitor tests part 6
parent
6e477595
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
-0
47 additions, 0 deletions
pkg/service/v1/config-service_test.go
with
47 additions
and
0 deletions
pkg/service/v1/config-service_test.go
+
47
−
0
View file @
bd6235f9
...
...
@@ -3,6 +3,7 @@ package v1
import
(
"code.geant.net/stash/scm/nmaas/nmaas-janitor/pkg/api/v1"
"context"
"github.com/xanzy/go-gitlab"
extension
"k8s.io/api/extensions/v1beta1"
corev1
"k8s.io/api/core/v1"
v12
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
...
@@ -192,4 +193,50 @@ func TestBasicAuthServiceServer_CreateOrReplace(t *testing.T) {
if
err
!=
nil
||
sec
==
nil
{
t
.
Fail
()
}
//Should update secret when already exists
res
,
err
=
server
.
CreateOrReplace
(
context
.
Background
(),
&
req
)
if
res
.
Status
!=
v1
.
Status_OK
||
err
!=
nil
{
t
.
Fail
()
}
}
func
TestConfigServiceServer_DeleteIfExists
(
t
*
testing
.
T
)
{
client
:=
testclient
.
NewSimpleClientset
()
gitclient
:=
gitlab
.
Client
{}
server
:=
NewConfigServiceServer
(
client
,
&
gitclient
)
//Should fail on api check
res
,
err
:=
server
.
DeleteIfExists
(
context
.
Background
(),
&
illegal_req
)
if
res
!=
nil
||
err
==
nil
{
t
.
Fail
()
}
//Should fail on namespace check
res
,
err
=
server
.
DeleteIfExists
(
context
.
Background
(),
&
req
)
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
)
//Should fail on configmap check
res
,
err
=
server
.
DeleteIfExists
(
context
.
Background
(),
&
req
)
if
err
==
nil
||
res
.
Status
!=
v1
.
Status_FAILED
{
t
.
Fail
()
}
//create mock configmap
cm
:=
corev1
.
ConfigMap
{}
cm
.
Name
=
"test-uid"
_
,
_
=
client
.
CoreV1
()
.
ConfigMaps
(
"test-namespace"
)
.
Create
(
&
cm
)
//should pass
res
,
err
=
server
.
DeleteIfExists
(
context
.
Background
(),
&
req
)
if
err
!=
nil
||
res
.
Status
!=
v1
.
Status_OK
{
t
.
Fail
()
}
}
\ 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