Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
violinist_teams
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
violinist_teams
Commits
4b65437c
Commit
4b65437c
authored
10 months ago
by
Eirik Morland
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3440970
by eiriksm: Provide a way to disconnect a provider from a team
parent
251e8b96
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!50
Add the methods and a test
Pipeline
#146707
passed with warnings
10 months ago
Stage: build
Stage: validate
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/TeamManager.php
+22
-0
22 additions, 0 deletions
src/TeamManager.php
tests/src/Kernel/TeamManagerTest.php
+24
-0
24 additions, 0 deletions
tests/src/Kernel/TeamManagerTest.php
with
46 additions
and
0 deletions
src/TeamManager.php
+
22
−
0
View file @
4b65437c
...
...
@@ -158,6 +158,28 @@ class TeamManager {
return
$this
->
state
->
get
(
self
::
getVcsProviderStateKey
(
$node
),
[]);
}
/**
* Remove one connection, by key.
*
* Please note that this will complete and not fail even if the connection
* does not currently exist.
*/
public
function
removeVcsConnection
(
TeamNode
$node
,
string
$provider_id
)
{
$connections
=
$this
->
getVcsConnections
(
$node
);
if
(
empty
(
$connections
[
$provider_id
]))
{
return
;
}
unset
(
$connections
[
$provider_id
]);
$this
->
setVcsConnections
(
$node
,
$connections
);
}
/**
* Setter for all connections.
*/
public
function
setVcsConnections
(
TeamNode
$node
,
array
$connections
)
{
$this
->
state
->
set
(
self
::
getVcsProviderStateKey
(
$node
),
$connections
);
}
/**
* Get the state key we use to store connections for it.
*/
...
...
This diff is collapsed.
Click to expand it.
tests/src/Kernel/TeamManagerTest.php
+
24
−
0
View file @
4b65437c
...
...
@@ -166,4 +166,28 @@ class TeamManagerTest extends KernelTestBase {
self
::
assertNotEquals
(
$hash1
,
$hash5
);
}
/**
* Test all of the connection setters and getters.
*/
public
function
testConnectionMethods
()
{
$team
=
Node
::
create
([
'type'
=>
$this
->
nodeType
->
id
(),
'title'
=>
'test'
,
]);
$team
->
save
();
$this
->
teamManager
->
setVcsConnection
(
$team
,
'github'
,
'mytoken'
);
self
::
assertArrayHasKey
(
'github'
,
$this
->
teamManager
->
getVcsConnections
(
$team
));
self
::
assertEquals
(
'mytoken'
,
$this
->
teamManager
->
getVcsConnection
(
$team
,
'github'
));
$this
->
teamManager
->
setVcsConnection
(
$team
,
'gitlab'
,
'mytoken2'
);
self
::
assertArrayHasKey
(
'gitlab'
,
$this
->
teamManager
->
getVcsConnections
(
$team
));
self
::
assertEquals
(
'mytoken2'
,
$this
->
teamManager
->
getVcsConnection
(
$team
,
'gitlab'
));
// Remove the github one, and ensure its not there any more.
$this
->
teamManager
->
removeVcsConnection
(
$team
,
'github'
);
self
::
assertArrayNotHasKey
(
'github'
,
$this
->
teamManager
->
getVcsConnections
(
$team
));
// And let's also nuke it entirely by setting it to an empty array. This
// should remove the gitlab one.
$this
->
teamManager
->
setVcsConnections
(
$team
,
[]);
self
::
assertEmpty
(
$this
->
teamManager
->
getVcsConnections
(
$team
));
}
}
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