{"action":"created","issue":{"url":"https://api.github.com/repos/jinzhu/gorm/issues/716","labels_url":"https://api.github.com/repos/jinzhu/gorm/issues/716/labels{/name}","comments_url":"https://api.github.com/repos/jinzhu/gorm/issues/716/comments","events_url":"https://api.github.com/repos/jinzhu/gorm/issues/716/events","html_url":"https://github.com/jinzhu/gorm/issues/716","id":115557752,"number":716,"title":"Fix Gorm Tests (Incorrect Package)","user":{"login":"dabfleming","id":3885717,"avatar_url":"https://avatars.githubusercontent.com/u/3885717?v=3","gravatar_id":"","url":"https://api.github.com/users/dabfleming","html_url":"https://github.com/dabfleming","followers_url":"https://api.github.com/users/dabfleming/followers","following_url":"https://api.github.com/users/dabfleming/following{/other_user}","gists_url":"https://api.github.com/users/dabfleming/gists{/gist_id}","starred_url":"https://api.github.com/users/dabfleming/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dabfleming/subscriptions","organizations_url":"https://api.github.com/users/dabfleming/orgs","repos_url":"https://api.github.com/users/dabfleming/repos","events_url":"https://api.github.com/users/dabfleming/events{/privacy}","received_events_url":"https://api.github.com/users/dabfleming/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jinzhu/gorm/labels/%23docs","name":"#docs","color":"0052cc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-11-06T18:08:46Z","updated_at":"2015-12-28T03:33:32Z","closed_at":null,"body":"From the [documentation on testing](https://golang.org/pkg/testing/)\r\n> To write a new test suite, create a file whose name ends _test.go that contains the TestXxx functions as described here. Put the file in the same package as the one being tested.\r\n\r\nGorm's test files should all be in the `gorm` package, not the `gorm_test` package. Additionally, because some of the test files import `\"github.com/jinzhu/gorm\"` a contributor working in their fork of gorm is not running all test code against their fork.\r\n\r\n### Example\r\n\r\n- Create `$GOPATH/src/github.com/username/gorm/` and clone/checkout 67f88d9 (current master as of this writing).\r\n- In `$GOPATH/src/github.com/jinzhu/gorm` checkout 5f113dc\r\n- `GORM_DIALECT=postgres go test github.com/username/gorm` will succeed.\r\n- In `$GOPATH/src/github.com/jinzhu/gorm` checkout 67f88d9\r\n- `GORM_DIALECT=postgres go test github.com/username/gorm` will fail.\r\n\r\nThis has allowed the addition of bugs (see below) which don't break tests initially, but do after they have been merged.\r\n\r\n### TODO\r\n\r\n- All files should be in package `gorm`\r\n- None should import `\"github.com/jinzhu/gorm\"`, all references to gorm should be to the current package.\r\n\r\nie. Make the changes proposed in PR #144. I understand your objection there, however note that dependencies that are only in test files are not needed to build the project, only to test it, and are only fetched when using the `-t` flag with go get.\r\n\r\nI would be happy to supply PR if you'd like.\r\n\r\n### References\r\n\r\nThis issue is the root cause of the confusion in #140. It allowed the introduction of #710 (Note that `GORM_DIALECT=postgres go test github.com/jinzhu/gorm` fails in panic on current master, 67f88d9). If the tests ran properly, the current panic would have been caught and #709 would have been added before merging #708 "},"comment":{"url":"https://api.github.com/repos/jinzhu/gorm/issues/comments/167469177","html_url":"https://github.com/jinzhu/gorm/issues/716#issuecomment-167469177","issue_url":"https://api.github.com/repos/jinzhu/gorm/issues/716","id":167469177,"user":{"login":"mark-adams","id":472350,"avatar_url":"https://avatars.githubusercontent.com/u/472350?v=3","gravatar_id":"","url":"https://api.github.com/users/mark-adams","html_url":"https://github.com/mark-adams","followers_url":"https://api.github.com/users/mark-adams/followers","following_url":"https://api.github.com/users/mark-adams/following{/other_user}","gists_url":"https://api.github.com/users/mark-adams/gists{/gist_id}","starred_url":"https://api.github.com/users/mark-adams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mark-adams/subscriptions","organizations_url":"https://api.github.com/users/mark-adams/orgs","repos_url":"https://api.github.com/users/mark-adams/repos","events_url":"https://api.github.com/users/mark-adams/events{/privacy}","received_events_url":"https://api.github.com/users/mark-adams/received_events","type":"User","site_admin":false},"created_at":"2015-12-28T03:33:32Z","updated_at":"2015-12-28T03:33:32Z","body":"It's probably also worth pointing out here that using a \"gorm_test\" package is also acceptable:\r\n\r\n> Test files that declare a package with the suffix \"_test\" will be compiled as a\r\nseparate package, and then linked and run with the main test binary."}}