Skip to content

Commit

Permalink
(#74) Merge pull request #169 from iakunin/74
Browse files Browse the repository at this point in the history
#74 - AllItemsIntegrationTest: extra tests were added
  • Loading branch information
iakunin authored May 7, 2020
2 parents 497e15b + 1ea24c7 commit ef19e4f
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import com.github.database.rider.core.api.dataset.DataSet;
import com.github.database.rider.core.api.dataset.ExpectedDataSet;
import com.github.tomakehurst.wiremock.client.WireMock;
import dev.iakunin.codexiabot.AbstractIntegrationTest;
import dev.iakunin.codexiabot.util.WireMockServer;
import dev.iakunin.codexiabot.util.wiremock.Request;
import dev.iakunin.codexiabot.util.wiremock.Response;
import dev.iakunin.codexiabot.util.wiremock.Stub;
import org.cactoos.io.ResourceOf;
Expand Down Expand Up @@ -42,7 +44,26 @@ public void oneActiveItem() {
WireMockServer.stub(
new Stub(
"/item/2222.json",
new ResourceOf("wiremock/hackernews/cron/health-check/all-items/oneActiveItem.json")
new ResourceOf("wiremock/hackernews/cron/health-check/all-items/activeItem.json")
)
);

allItems.run();
}

@Test
@DataSet(
value = "db-rider/hackernews/cron/health-check/all-items/initial/twoActiveItems.yml",
cleanBefore = true, cleanAfter = true
)
@ExpectedDataSet("db-rider/hackernews/cron/health-check/all-items/expected/twoActiveItems.yml")
public void twoActiveItems() {
WireMockServer.stub(
new Stub(
new Request(WireMock.urlPathMatching("/item/\\d+\\.json")),
new Response(
new ResourceOf("wiremock/hackernews/cron/health-check/all-items/activeItem.json")
)
)
);

Expand All @@ -59,7 +80,26 @@ public void oneDeletedItem() {
WireMockServer.stub(
new Stub(
"/item/2222.json",
new ResourceOf("wiremock/hackernews/cron/health-check/all-items/oneDeletedItem.json")
new ResourceOf("wiremock/hackernews/cron/health-check/all-items/deletedItem.json")
)
);

allItems.run();
}

@Test
@DataSet(
value = "db-rider/hackernews/cron/health-check/all-items/initial/twoDeletedItems.yml",
cleanBefore = true, cleanAfter = true
)
@ExpectedDataSet("db-rider/hackernews/cron/health-check/all-items/expected/twoDeletedItems.yml")
public void twoDeletedItems() {
WireMockServer.stub(
new Stub(
new Request(WireMock.urlPathMatching("/item/\\d+\\.json")),
new Response(
new ResourceOf("wiremock/hackernews/cron/health-check/all-items/deletedItem.json")
)
)
);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
github_repo_source:
-
github_repo_id: 1
source: "HACKERNEWS"
external_id: "2222"
-
github_repo_id: 2
source: "HACKERNEWS"
external_id: "3333"

hackernews_item:
-
external_id: 2222
type: story
by: smartmic
title: Title for casbin
url: https://github.com/casbin/casbin
time: 2020-02-14 18:43:33
deleted: false
-
external_id: 3333
type: story
by: test-author
title: Title for test-post
url: https://github.com/test/test
time: 2002-02-14 18:43:33
deleted: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
github_repo_source:
-
github_repo_id: 1
source: "HACKERNEWS"
external_id: "2222"
deleted_at: regex:^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{1,6}$
-
github_repo_id: 2
source: "HACKERNEWS"
external_id: "3333"
deleted_at: regex:^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{1,6}$

hackernews_item:
-
external_id: 2222
type: story
by: smartmic
title: Title for casbin
url: https://github.com/casbin/casbin
time: 2009-01-15 05:56:02
deleted: true
-
external_id: 3333
type: story
by: smartmic
title: Title for casbin
url: https://github.com/casbin/casbin
time: 2009-01-15 05:56:02
deleted: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
github_repo:
-
id: 1
uuid: "groovy: UUID.randomUUID().toString()"
external_id: 202275988
full_name: casbin/casbin
html_url: https://github.com/casbin/casbin
repo_created_at: 2019-08-14 04:42:36
-
id: 2
uuid: "groovy: UUID.randomUUID().toString()"
external_id: 303123123
full_name: test/test
html_url: https://github.com/test/test
repo_created_at: 2017-01-03 12:02:11

github_repo_source:
-
uuid: "groovy: UUID.randomUUID().toString()"
github_repo_id: 1
source: "HACKERNEWS"
external_id: "2222"
-
uuid: "groovy: UUID.randomUUID().toString()"
github_repo_id: 2
source: "HACKERNEWS"
external_id: "3333"

hackernews_item:
-
uuid: "groovy: UUID.randomUUID().toString()"
external_id: 2222
type: story
by: smartmic
title: Title for casbin
url: https://github.com/casbin/casbin
time: 2020-02-14 18:43:33
deleted: false
-
uuid: "groovy: UUID.randomUUID().toString()"
external_id: 3333
type: story
by: test-author
title: Title for test-post
url: https://github.com/test/test
time: 2002-02-14 18:43:33
deleted: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
github_repo:
-
id: 1
uuid: "groovy: UUID.randomUUID().toString()"
external_id: 202275988
full_name: casbin/casbin
html_url: https://github.com/casbin/casbin
repo_created_at: 2019-08-14 04:42:36
-
id: 2
uuid: "groovy: UUID.randomUUID().toString()"
external_id: 303123123
full_name: test/test
html_url: https://github.com/test/test
repo_created_at: 2017-01-03 12:02:11

github_repo_source:
-
uuid: "groovy: UUID.randomUUID().toString()"
github_repo_id: 1
source: "HACKERNEWS"
external_id: "2222"
-
uuid: "groovy: UUID.randomUUID().toString()"
github_repo_id: 2
source: "HACKERNEWS"
external_id: "3333"

hackernews_item:
-
uuid: "groovy: UUID.randomUUID().toString()"
external_id: 2222
type: story
by: smartmic
title: Title for casbin
url: https://github.com/casbin/casbin
time: 2020-02-14 18:43:33
deleted: false
-
uuid: "groovy: UUID.randomUUID().toString()"
external_id: 3333
type: story
by: test-author
title: Title for test-post
url: https://github.com/test/test
time: 2002-02-14 18:43:33
deleted: false

0 comments on commit ef19e4f

Please sign in to comment.