Skip to content

Commit

Permalink
add tests for getOptionalStringSet and getStringSet from CommonCo…
Browse files Browse the repository at this point in the history
…nfig
  • Loading branch information
twrichards committed Jun 26, 2024
1 parent 8a5cd46 commit 93bcbb5
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.gu.mediaservice.lib.config

import org.mockito.Mockito.when
import org.scalatest.funsuite.AnyFunSuiteLike
import org.scalatest.matchers.should.Matchers.convertToAnyShouldWrapper
import org.scalatestplus.mockito.MockitoSugar
import play.api.Configuration

class CommonConfigTest extends AnyFunSuiteLike with MockitoSugar {

private val commonConf = mock[CommonConfig]
when(commonConf.configuration).thenReturn(Configuration(
"setAsCommaSepString" -> "a, b,c",
"setAsActualArray" -> Set("a", "b", "c")
))

test("testGetOptionalStringSet") {
commonConf.getOptionalStringSet("doesnt.exist") shouldBe None
commonConf.getOptionalStringSet("setAsCommaSepString") shouldBe Some(Set("a", "b", "c"))
commonConf.getOptionalStringSet("setAsActualArray") shouldBe Some(Set("a", "b", "c"))
}

test("testGetStringSet") {
commonConf.getStringSet("doesnt.exist") shouldBe Set.empty
commonConf.getStringSet("setAsCommaSepString") shouldBe Set("a", "b", "c")
commonConf.getStringSet("setAsActualArray") shouldBe Set("a", "b", "c")
}

}

0 comments on commit 93bcbb5

Please sign in to comment.