Skip to content

Commit

Permalink
refactor(test): move some val into beforeAll
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshinorin committed Jul 21, 2024
1 parent 62dd168 commit b1ae31a
Show file tree
Hide file tree
Showing 11 changed files with 164 additions and 174 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import cats.effect.unsafe.implicits.global
// testOnly net.yoshinorin.qualtet.domains.ArchiveServiceSpec
class ArchiveServiceSpec extends AnyWordSpec with BeforeAndAfterAll {

val requestContents = makeRequestContents(40, "archives")

override protected def beforeAll(): Unit = {
// NOTE: create content and related data for test
val requestContents = makeRequestContents(40, "archives")
createContents(requestContents)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,27 @@ import cats.effect.unsafe.implicits.global
// testOnly net.yoshinorin.qualtet.domains.ArticleServiceSpec
class ArticleServiceSpec extends AnyWordSpec with BeforeAndAfterAll {

val sameTagNameRequestContents: List[RequestContent] = {
(1 until 15).toList
.map(_.toString())
.map(i =>
RequestContent(
contentType = "article",
path = Path(s"/test/same/tags/${i}"),
title = s"this is a same tag title ${i}",
rawContent = s"this is a same tag raw content ${i}",
htmlContent = s"this is a html content ${i}",
robotsAttributes = Attributes("noarchive, noimageindex"),
tags = List("SameTag"),
externalResources = List()
)
)
}

val requestContents = makeRequestContents(30, "articles")

override protected def beforeAll(): Unit = {
// NOTE: create content and related data for test
val requestContents = makeRequestContents(30, "articles")
createContents(requestContents)

val sameTagNameRequestContents: List[RequestContent] = {
(1 until 15).toList
.map(_.toString())
.map(i =>
RequestContent(
contentType = "article",
path = Path(s"/test/same/tags/${i}"),
title = s"this is a same tag title ${i}",
rawContent = s"this is a same tag raw content ${i}",
htmlContent = s"this is a html content ${i}",
robotsAttributes = Attributes("noarchive, noimageindex"),
tags = List("SameTag"),
externalResources = List()
)
)
}
createContents(sameTagNameRequestContents)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,32 @@ import org.scalatest.Ignore
@Ignore // TODO: write testcode when implement delete feature
class ContentSerializingServiceSpec extends AnyWordSpec with BeforeAndAfterAll {

val requestSeries: RequestSeries = RequestSeries(
title = "Content Serializing Service Spec",
name = SeriesName("content-serializing-service-spec"),
None
)

val requestContents: List[RequestContent] = {
List(1, 5)
.map(_.toString())
.map(i =>
RequestContent(
contentType = "article",
path = Path(s"/test/ContentSerializingServiceSpec-${i}"),
title = s"this is a ContentSerializingServiceSpec title ${i}",
rawContent = s"this is a ContentSerializingServiceSpec raw content ${i}",
htmlContent = s"this is a ContentSerializingServiceSpec html content ${i}",
robotsAttributes = Attributes("noarchive, noimageindex"),
tags = List(s"ContentSerializingServiceSpec${i}.1", s"ContentSerializingServiceSpec${i}.2", s"ContentSerializingServiceSpec${i}.3"),
series = Option(requestSeries.name),
externalResources = List()
)
)
}

override protected def beforeAll(): Unit = {
createSeries(List(requestSeries))
// NOTE: create content and related data for test
val requestSeries: RequestSeries = RequestSeries(
title = "Content Serializing Service Spec",
name = SeriesName("content-serializing-service-spec"),
None
)
createSeries(List(requestSeries))

val requestContents: List[RequestContent] = {
List(1, 5)
.map(_.toString())
.map(i =>
RequestContent(
contentType = "article",
path = Path(s"/test/ContentSerializingServiceSpec-${i}"),
title = s"this is a ContentSerializingServiceSpec title ${i}",
rawContent = s"this is a ContentSerializingServiceSpec raw content ${i}",
htmlContent = s"this is a ContentSerializingServiceSpec html content ${i}",
robotsAttributes = Attributes("noarchive, noimageindex"),
tags = List(s"ContentSerializingServiceSpec${i}.1", s"ContentSerializingServiceSpec${i}.2", s"ContentSerializingServiceSpec${i}.3"),
series = Option(requestSeries.name),
externalResources = List()
)
)
}
createContents(requestContents)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,24 @@ class ContentTaggingServiceSpec extends AnyWordSpec with BeforeAndAfterAll {

given doobieExecuterContext: DoobieExecuter = new DoobieExecuter(fixtureTx)

val requestContents: List[RequestContent] = {
List(1, 2)
.map(_.toString())
.map(i =>
RequestContent(
contentType = "article",
path = Path(s"/test/ContentTaggingServiceSpec-${i}"),
title = s"this is a ContentTaggingServiceSpec title ${i}",
rawContent = s"this is a ContentTaggingServiceSpec raw content ${i}",
htmlContent = s"this is a ContentTaggingServiceSpec html content ${i}",
robotsAttributes = Attributes("noarchive, noimageindex"),
tags = List(s"ContentTaggingServiceSpec${i}.1", s"ContentTaggingServiceSpec${i}.2", s"ContentTaggingServiceSpec${i}.3"),
externalResources = List()
)
)
}

override protected def beforeAll(): Unit = {
// NOTE: create content and related data for test
val requestContents: List[RequestContent] = {
List(1, 2)
.map(_.toString())
.map(i =>
RequestContent(
contentType = "article",
path = Path(s"/test/ContentTaggingServiceSpec-${i}"),
title = s"this is a ContentTaggingServiceSpec title ${i}",
rawContent = s"this is a ContentTaggingServiceSpec raw content ${i}",
htmlContent = s"this is a ContentTaggingServiceSpec html content ${i}",
robotsAttributes = Attributes("noarchive, noimageindex"),
tags = List(s"ContentTaggingServiceSpec${i}.1", s"ContentTaggingServiceSpec${i}.2", s"ContentTaggingServiceSpec${i}.3"),
externalResources = List()
)
)
}
createContents(requestContents)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import cats.effect.unsafe.implicits.global
// testOnly net.yoshinorin.qualtet.domains.FeedServiceSpec
class FeedServiceSpec extends AnyWordSpec with BeforeAndAfterAll {

val requestContents = makeRequestContents(30, "feeds")

override protected def beforeAll(): Unit = {
// NOTE: create content and related data for test
val requestContents = makeRequestContents(30, "feeds")
createContents(requestContents)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,70 +13,69 @@ import cats.effect.unsafe.implicits.global
// testOnly net.yoshinorin.qualtet.domains.search.SearchServiceSpec
class SearchServiceSpec extends AnyWordSpec with BeforeAndAfterAll {

val requestContents: List[RequestContent] = {
(0 until 49).toList
.map(_.toString())
.map(i =>
RequestContent(
contentType = "article",
path = Path(s"/test/searchService-${i}"),
title = s"this is a searchService title ${i}",
rawContent = s"this is a searchService raw content ${i}",
htmlContent = s"this is a searchService html content ${i}",
robotsAttributes = Attributes("noarchive, noimageindex"),
tags = List(s"searchService${i}"),
externalResources = List()
)
) :+ RequestContent(
contentType = "article",
path = Path(s"/test/searchServiceLast"),
title = s"this is a searchService titleLast",
rawContent = s"this is a searchService raw contentLast",
htmlContent = s"this is a searchService html contentLast",
robotsAttributes = Attributes("noarchive, noimageindex"),
tags = List(s"searchServiceLast"),
externalResources = List()
) :+ RequestContent(
contentType = "article",
path = Path(s"/test/searchServiceIncludesUrl1"),
title = s"this is a searchService IncludesUrl1",
rawContent = s"this is a searchService raw contentIncludesUrl1 https://example.com aaabbbccc",
htmlContent = s"this is a searchService html contentIncludesUrl1 https://example.com aaabbbccc",
robotsAttributes = Attributes("noarchive, noimageindex"),
tags = List(s"IncludesUrl1"),
externalResources = List()
) :+ RequestContent(
contentType = "article",
path = Path(s"/test/searchServiceIncludesUrl2"),
title = s"this is a searchService IncludesUrl2",
rawContent = s"this is a searchService raw contentIncludesUrl2 http://example.com aaabbbccc",
htmlContent = s"this is a searchService html contentIncludesUrl2 http://example.com aaabbbccc",
robotsAttributes = Attributes("noarchive, noimageindex"),
tags = List(s"IncludesUrl2"),
externalResources = List()
) :+ RequestContent(
contentType = "article",
path = Path(s"/test/searchServiceIncludesWrongUrl"),
title = s"this is a searchService IncludesWrongUrl1",
rawContent = s"this is a searchService raw contentIncludesWrongUrl1 htt://example.com aaabbbccc",
htmlContent = s"this is a searchService html contentIncludesWrongUrl1 htt://example.com aaabbbccc",
robotsAttributes = Attributes("noarchive, noimageindex"),
tags = List(s"IncludesWrongUrl1"),
externalResources = List()
) :+ RequestContent(
contentType = "article",
path = Path(s"/test/searchServiceIncludesHttpString"),
title = s"this is a searchService IncludesHttpString",
rawContent = s"this is a searchService raw contentIncludesHttp String http://example.com aaabbbccc http",
htmlContent = s"this is a searchService html contentIncludesHttp String http://example.com aaabbbccc http",
robotsAttributes = Attributes("noarchive, noimageindex"),
tags = List(s"IncludesHttpString"),
externalResources = List()
)
}

override protected def beforeAll(): Unit = {
// NOTE: create content and related data for test
val requestContents: List[RequestContent] = {
(0 until 49).toList
.map(_.toString())
.map(i =>
RequestContent(
contentType = "article",
path = Path(s"/test/searchService-${i}"),
title = s"this is a searchService title ${i}",
rawContent = s"this is a searchService raw content ${i}",
htmlContent = s"this is a searchService html content ${i}",
robotsAttributes = Attributes("noarchive, noimageindex"),
tags = List(s"searchService${i}"),
externalResources = List()
)
) :+ RequestContent(
contentType = "article",
path = Path(s"/test/searchServiceLast"),
title = s"this is a searchService titleLast",
rawContent = s"this is a searchService raw contentLast",
htmlContent = s"this is a searchService html contentLast",
robotsAttributes = Attributes("noarchive, noimageindex"),
tags = List(s"searchServiceLast"),
externalResources = List()
) :+ RequestContent(
contentType = "article",
path = Path(s"/test/searchServiceIncludesUrl1"),
title = s"this is a searchService IncludesUrl1",
rawContent = s"this is a searchService raw contentIncludesUrl1 https://example.com aaabbbccc",
htmlContent = s"this is a searchService html contentIncludesUrl1 https://example.com aaabbbccc",
robotsAttributes = Attributes("noarchive, noimageindex"),
tags = List(s"IncludesUrl1"),
externalResources = List()
) :+ RequestContent(
contentType = "article",
path = Path(s"/test/searchServiceIncludesUrl2"),
title = s"this is a searchService IncludesUrl2",
rawContent = s"this is a searchService raw contentIncludesUrl2 http://example.com aaabbbccc",
htmlContent = s"this is a searchService html contentIncludesUrl2 http://example.com aaabbbccc",
robotsAttributes = Attributes("noarchive, noimageindex"),
tags = List(s"IncludesUrl2"),
externalResources = List()
) :+ RequestContent(
contentType = "article",
path = Path(s"/test/searchServiceIncludesWrongUrl"),
title = s"this is a searchService IncludesWrongUrl1",
rawContent = s"this is a searchService raw contentIncludesWrongUrl1 htt://example.com aaabbbccc",
htmlContent = s"this is a searchService html contentIncludesWrongUrl1 htt://example.com aaabbbccc",
robotsAttributes = Attributes("noarchive, noimageindex"),
tags = List(s"IncludesWrongUrl1"),
externalResources = List()
) :+ RequestContent(
contentType = "article",
path = Path(s"/test/searchServiceIncludesHttpString"),
title = s"this is a searchService IncludesHttpString",
rawContent = s"this is a searchService raw contentIncludesHttp String http://example.com aaabbbccc http",
htmlContent = s"this is a searchService html contentIncludesHttp String http://example.com aaabbbccc http",
robotsAttributes = Attributes("noarchive, noimageindex"),
tags = List(s"IncludesHttpString"),
externalResources = List()
)
}
createContents(requestContents)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,22 @@ import cats.effect.unsafe.implicits.global
// testOnly net.yoshinorin.qualtet.domains.SeriesServiceSpec
class SeriesServiceSpec extends AnyWordSpec with BeforeAndAfterAll {

val requestSeries: List[RequestSeries] = List(
RequestSeries(
title = "Series Service Spec",
name = SeriesName("seriesservice-series"),
None
),
RequestSeries(
title = "Series Service Spec2",
name = SeriesName("seriesservice-series2"),
None
)
)

val requestContents = makeRequestContents(5, "SeriesService", Some(requestSeries.head.name))

override protected def beforeAll(): Unit = {
val requestSeries: List[RequestSeries] = List(
RequestSeries(
title = "Series Service Spec",
name = SeriesName("seriesservice-series"),
None
),
RequestSeries(
title = "Series Service Spec2",
name = SeriesName("seriesservice-series2"),
None
)
)
createSeries(requestSeries)

val requestContents = makeRequestContents(5, "SeriesService", Some(requestSeries.head.name))
createContents(requestContents)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ class TagServiceSpec extends AnyWordSpec with BeforeAndAfterAll {

given doobieExecuterContext: DoobieExecuter = new DoobieExecuter(fixtureTx)

val requestContents = makeRequestContents(10, "tagService")

override protected def beforeAll(): Unit = {
// NOTE: create content and related data for test
val requestContents = makeRequestContents(10, "tagService")
createContents(requestContents)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ import cats.effect.unsafe.implicits.global
// testOnly net.yoshinorin.qualtet.http.routes.v1.FeedRouteSpec
class FeedRouteV1Spec extends AnyWordSpec with BeforeAndAfterAll {

val requestContents = makeRequestContents(2, "feedsRoute")

override protected def beforeAll(): Unit = {
// NOTE: create content and related data for test
val requestContents = makeRequestContents(2, "feedsRoute")
createContents(requestContents)
}

Expand Down
Loading

0 comments on commit b1ae31a

Please sign in to comment.