-
Notifications
You must be signed in to change notification settings - Fork 502
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finalize the implementation and add tests
- Loading branch information
Ender Tunc
committed
Mar 18, 2023
1 parent
58e6793
commit 42e72d3
Showing
7 changed files
with
320 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
modules/core/src/test/scala/org/scalasteward/core/forge/gitlab/GitLabAlgTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package org.scalasteward.core.forge.gitlab | ||
|
||
import munit.CatsEffectSuite | ||
import org.http4s.Request | ||
import org.scalasteward.core.TestInstances.ioLogger | ||
import org.scalasteward.core.application.Config.{GitLabCfg, MergeRequestApprovalRulesCfg} | ||
import org.scalasteward.core.data.Repo | ||
import org.scalasteward.core.forge.ForgeType | ||
import org.scalasteward.core.mock.MockConfig.config | ||
import org.scalasteward.core.mock.MockContext.context.httpJsonClient | ||
import org.scalasteward.core.mock.MockEff | ||
import org.scalasteward.core.util.Nel | ||
|
||
class GitLabAlgTest extends CatsEffectSuite { | ||
|
||
private val gitlabApiAlg = new GitLabApiAlg[MockEff]( | ||
forgeCfg = config.forgeCfg.copy(tpe = ForgeType.GitLab), | ||
gitLabCfg = GitLabCfg(mergeWhenPipelineSucceeds = false, requiredApprovals = None), | ||
modify = (_: Repo) => (request: Request[MockEff]) => MockEff.pure(request) | ||
) | ||
|
||
test( | ||
"calculateRulesToUpdate -- ignore active approval rule that doesn't have approval rule configuration" | ||
) { | ||
val activeApprovalRules = | ||
List( | ||
MergeRequestLevelApprovalRuleOut(name = "A", id = 101), | ||
MergeRequestLevelApprovalRuleOut(name = "B", id = 201) | ||
) | ||
val approvalRulesCfg = | ||
Nel.one(MergeRequestApprovalRulesCfg(approvalRuleName = "B", requiredApprovals = 1)) | ||
|
||
val result = | ||
gitlabApiAlg.calculateRulesToUpdate(activeApprovalRules, approvalRulesCfg) | ||
val expectedResult = | ||
List( | ||
( | ||
MergeRequestApprovalRulesCfg(approvalRuleName = "B", requiredApprovals = 1), | ||
MergeRequestLevelApprovalRuleOut(id = 201, name = "B") | ||
) | ||
) | ||
|
||
assertEquals(result, expectedResult) | ||
} | ||
|
||
test( | ||
"calculateRulesToUpdate -- ignore approval rule configuration that doesn't have active approval rule" | ||
) { | ||
val activeApprovalRules = | ||
List(MergeRequestLevelApprovalRuleOut(name = "A", id = 101)) | ||
val approvalRulesCfg = | ||
Nel.of( | ||
MergeRequestApprovalRulesCfg(approvalRuleName = "A", requiredApprovals = 1), | ||
MergeRequestApprovalRulesCfg(approvalRuleName = "B", requiredApprovals = 2) | ||
) | ||
|
||
val result = | ||
gitlabApiAlg.calculateRulesToUpdate(activeApprovalRules, approvalRulesCfg) | ||
val expectedResult = | ||
List( | ||
( | ||
MergeRequestApprovalRulesCfg(approvalRuleName = "A", requiredApprovals = 1), | ||
MergeRequestLevelApprovalRuleOut(name = "A", id = 101) | ||
) | ||
) | ||
|
||
assertEquals(result, expectedResult) | ||
} | ||
} |
Oops, something went wrong.