Skip to content

Commit

Permalink
Update Show instances to not show values
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Lövgren committed Jun 16, 2018
1 parent 8de5916 commit b62a940
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,16 @@ import ciris._

trait CirisInstancesForCats {
implicit def showConfigEntry[F[_], K, S, V](
implicit showK: Show[K],
showS: Show[F[Either[ConfigError, S]]],
showV: Show[F[Either[ConfigError, V]]]
implicit showKey: Show[K],
showKeyType: Show[ConfigKeyType[K]]
): Show[ConfigEntry[F, K, S, V]] = Show.show { entry =>
val key = showK.show(entry.key)
val keyType = showConfigKeyType[K].show(entry.keyType)
val sourceValue = showS.show(entry.sourceValue)
val value = showV.show(entry.value)

if (sourceValue == value) s"ConfigEntry($key, $keyType, $value)"
else s"ConfigEntry($key, $keyType, $sourceValue, $value)"
val key = showKey.show(entry.key)
val keyType = showKeyType.show(entry.keyType)
s"ConfigEntry($key, $keyType)"
}

implicit def showConfigValue[F[_], V](
implicit show: Show[F[Either[ConfigError, V]]]
): Show[ConfigValue[F, V]] = Show.show { value =>
s"ConfigValue(${show.show(value.value)})"
}
implicit def showConfigValue[F[_], V]: Show[ConfigValue[F, V]] =
Show.fromToString

implicit val showConfigError: Show[ConfigError] =
Show.fromToString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class CirisInstancesForCatsSpec extends PropertySpec {
List(Right("123"))
)
.mapValue(_.toInt)
) shouldBe "ConfigEntry(key, ConfigKeyType(keyType), List(Right(123)))"
) shouldBe "ConfigEntry(key, ConfigKeyType(keyType))"

Show[ConfigEntry[List, String, String, Int]].show(
ConfigEntry
Expand All @@ -31,11 +31,13 @@ final class CirisInstancesForCatsSpec extends PropertySpec {
List(Right("123"))
)
.mapValue(s => (s + "4").toInt)
) shouldBe "ConfigEntry(key, ConfigKeyType(keyType), List(Right(123)), List(Right(1234)))"
) shouldBe "ConfigEntry(key, ConfigKeyType(keyType))"

val configValue = ConfigValue.applyF[List, Int](List(right(123)))

Show[ConfigValue[List, Int]].show(
ConfigValue.applyF[List, Int](List(right(123)))
) shouldBe "ConfigValue(List(Right(123)))"
configValue
) shouldBe configValue.toString

Show[_root_.ciris.api.Id[Int]]
.show(123) shouldBe "123"
Expand Down

0 comments on commit b62a940

Please sign in to comment.