Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

Commit

Permalink
testfixture.GetTestFileAndFunc() (#2149)
Browse files Browse the repository at this point in the history
`GetTestFileAndFunc` returns the file and function of the first `_test.go` file to appear in the stack and returns it in this schema:

```
(see function github.com/fabric8-services/fabric8-wit/test/testfixture_test.TestGetGetTestFileAndFunc in test/testfixture/testfixture_test.go)
```

The result can be used to augment entities so that we always can tell which test created an entity that is a left-over and not cleaned up for example.

NOTE: The `testfixutre.GetTestFileAndFunc()` was taken out of this PR and already merge with this PR #2214. It is no longer part of this PR.

Most of the entities created with the `test/testfixture` package now contain a description that reveals in which function the entities was created. When there are left-over entities that hinder tests from running properly, you can now go in the database and find out which test produced these left-overs. To simplify things when running on CI, we now output a list of remaining spaces automatically that looks like this if everything went ok:

```
Check that no unexpected left-over spaces exist after running tests:

-[ RECORD 1 ]-------------------------------------

id          | 2e0698d8-753e-4cef-bb7c-f027634824a2

name        | system.space

description | Description of the space
```

Note, that the `system.space` is okay to appear in this list. It is expected even though it should go away at some point.

See #2278 for an example of a PR that was easily fixed because of this PR.
  • Loading branch information
kwk authored Sep 11, 2018
1 parent 426e11b commit a8fab53
Show file tree
Hide file tree
Showing 86 changed files with 281 additions and 69 deletions.
12 changes: 12 additions & 0 deletions .make/docker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@ ifeq ($(strip $(shell docker inspect --format '{{ .NetworkSettings.IPAddress }}'
endif
$(eval F8_POSTGRES_HOST := $(shell docker inspect --format '{{ .NetworkSettings.IPAddress }}' make_postgres_integration_test_1 2>/dev/null))
docker exec -t $(DOCKER_RUN_INTERACTIVE_SWITCH) "$(DOCKER_CONTAINER_NAME)" bash -ec 'export F8_POSTGRES_HOST=$(F8_POSTGRES_HOST); make $(makecommand)'
@echo
@echo "Check that no unexpected left-over spaces exist after running tests:"
@echo
@docker exec \
-t $(DOCKER_RUN_INTERACTIVE_SWITCH) \
"$(DOCKER_CONTAINER_NAME)" \
bash -ec 'PGPASSWORD=mysecretpassword \
psql -h $(F8_POSTGRES_HOST) \
-U postgres \
-c "SELECT id, name, description FROM spaces;" \
-x \
-P pager=off'

# This is a wildcard target to let you call any make target from the normal makefile
# but it will run inside the docker container. This target will only get executed if
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.builder
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN yum --enablerepo=centosplus install -y --quiet \
wget \
which \
bc \
postgresql \
&& yum clean all

RUN test -n $USE_GO_VERSION_FROM_WEBSITE \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"content": "# Description is modified1",
"markup": "Markdown"
},
"oldValue": {
"content": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*TestEvent).TestListEvent.func5 in controller/work_item_events_blackbox_test.go)`",
"markup": "Markdown"
},
"revisionId": "00000000-0000-0000-0000-000000000001",
"timestamp": "0001-01-01T00:00:00Z"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"attributes": {
"active_status": true,
"created-at": "0001-01-01T00:00:00Z",
"description": "Some description",
"description": "some description (see function github.com/fabric8-services/fabric8-wit/controller_test.(*TestIterationREST).TestShowIterationOK in controller/iteration_blackbox_test.go)",
"endAt": "0001-01-01T00:00:00Z",
"name": "iteration 00000000-0000-0000-0000-000000000001",
"parent_path": "/00000000-0000-0000-0000-000000000002",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"attributes": {
"active_status": false,
"created-at": "0001-01-01T00:00:00Z",
"description": "Some description",
"description": "some description (see function github.com/fabric8-services/fabric8-wit/controller_test.(*TestIterationREST).TestUpdateIteration.func1 in controller/iteration_blackbox_test.go)",
"name": "iteration 3",
"parent_path": "/00000000-0000-0000-0000-000000000001/00000000-0000-0000-0000-000000000002",
"resolved_parent_path": "/root/iteration 1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"data": {
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestUpdateWorkItem.func1 in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestUpdateWorkItem.func1 in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 2,
"system.order": 2000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"data": {
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestUpdateWorkItem.func1 in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestUpdateWorkItem.func1 in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 2,
"system.order": 2000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"data": {
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestUpdateWorkItem.func2 in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestUpdateWorkItem.func2 in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 2,
"system.order": 2000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"data": {
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestUpdateWorkItem.func2 in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestUpdateWorkItem.func2 in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 2,
"system.order": 2000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
{
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedChildren in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedChildren in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 2,
"system.order": 2000,
Expand Down Expand Up @@ -87,6 +90,9 @@
{
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedChildren in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedChildren in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 3,
"system.order": 3000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
{
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedChildren in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedChildren in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 2,
"system.order": 2000,
Expand Down Expand Up @@ -92,6 +95,9 @@
{
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedChildren in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedChildren in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 3,
"system.order": 3000,
Expand Down Expand Up @@ -183,6 +189,9 @@
{
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedChildren in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedChildren in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 1,
"system.order": 1000,
Expand Down Expand Up @@ -267,6 +276,9 @@
{
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedChildren in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedChildren in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 5,
"system.order": 5000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
{
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 1,
"system.order": 1000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
{
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 1,
"system.order": 1000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
{
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 2,
"system.order": 2000,
Expand Down Expand Up @@ -87,6 +90,9 @@
{
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 3,
"system.order": 3000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
{
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 2,
"system.order": 2000,
Expand Down Expand Up @@ -92,6 +95,9 @@
{
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 3,
"system.order": 3000,
Expand Down Expand Up @@ -183,6 +189,9 @@
{
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 1,
"system.order": 1000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
{
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 2,
"system.order": 2000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
{
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 2,
"system.order": 2000,
Expand Down Expand Up @@ -94,6 +97,9 @@
{
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 1,
"system.order": 1000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
{
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 3,
"system.order": 3000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
{
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 3,
"system.order": 3000,
Expand Down Expand Up @@ -94,6 +97,9 @@
{
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 1,
"system.order": 1000,
Expand Down Expand Up @@ -178,6 +184,9 @@
{
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 2,
"system.order": 2000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
{
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.description": "`(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)`",
"system.description.markup": "Markdown",
"system.description.rendered": "\u003cp\u003e\u003ccode\u003e(see function github.com/fabric8-services/fabric8-wit/controller_test.(*searchControllerTestSuite).TestIncludedParents in controller/search_blackbox_test.go)\u003c/code\u003e\u003c/p\u003e\n",
"system.metastate": null,
"system.number": 4,
"system.order": 4000,
Expand Down
Loading

0 comments on commit a8fab53

Please sign in to comment.