create-go-app / fiber-go-template

šŸ“ Production-ready backend template with Fiber Go Web Framework for Create Go App CLI.
https://github.com/create-go-app/cli/wiki
Apache License 2.0
925 stars 119 forks source link

Running make test results in failure #179

Open rickhlx opened 1 year ago

rickhlx commented 1 year ago

Required check list:

My environment:

Describe the bug:

Running make test results in the following error:

=== RUN   TestPrivateRoutes
    private_routes_test.go:108: 
                Error Trace:    /Users/xxx/src/xxx/xxx/pkg/routes/private_routes_test.go:108
                Error:          Not equal: 
                                expected: 404
                                actual  : 500
                Test:           TestPrivateRoutes
                Messages:       delete book with credentials
--- FAIL: TestPrivateRoutes (0.03s)
=== RUN   TestPublicRoutes
    public_routes_test.go:65: 
                Error Trace:    /Users/xxx/src/xxx/xxx/pkg/routes/public_routes_test.go:65
                Error:          Not equal: 
                                expected: 404
                                actual  : 500
                Test:           TestPublicRoutes
                Messages:       get book by ID
--- FAIL: TestPublicRoutes (0.00s)
FAIL
        github.com/xxx/xxx/pkg/routes     coverage: 73.3% of statements
FAIL    github.com/xxx/xxx/pkg/routes     0.535s
FAIL
make: *** [test] Error 1

Steps to reproduce the behavior:

  1. Clone the repo
  2. Install dependencies
  3. Run make test
  4. See error

Expected behavior:

No errors are expected from out-of-the-box.

Additional context:

The following error is returned from the request response body:

{
  "error": true,
  "msg": "error, not connected to database, failed to connect to `host=host.docker.internal user=postgres database=postgres`: hostname resolving error (lookup host.docker.internal: no such host)"
}
welcome[bot] commented 1 year ago

Thanks for opening your first issue here! šŸŽ‰ Be sure to follow the issue template!

koddr commented 1 year ago

Hi,

Are you sure what DB on your side is up? Could you please check this again before run tests?

stale[bot] commented 1 year ago

šŸ‘‹ Hello. Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

gaby commented 1 year ago

@koddr @rickhlx I get a different error:

go test -v -timeout 30s -coverprofile=cover.out -cover ./...
?       github.com/create-go-app/fiber-go-template  [no test files]
?       github.com/create-go-app/fiber-go-template/app/controllers  [no test files]
?       github.com/create-go-app/fiber-go-template/app/models   [no test files]
?       github.com/create-go-app/fiber-go-template/app/queries  [no test files]
?       github.com/create-go-app/fiber-go-template/pkg/configs  [no test files]
?       github.com/create-go-app/fiber-go-template/pkg/middleware   [no test files]
?       github.com/create-go-app/fiber-go-template/docs [no test files]
?       github.com/create-go-app/fiber-go-template/pkg/repository   [no test files]
?       github.com/create-go-app/fiber-go-template/pkg/utils    [no test files]
?       github.com/create-go-app/fiber-go-template/platform/cache   [no test files]
?       github.com/create-go-app/fiber-go-template/platform/database    [no test files]
=== RUN   TestPrivateRoutes
    private_routes_test.go:108: 
            Error Trace:    /home/ubuntu/Desktop/git/fix/fiber-go-template/pkg/routes/private_routes_test.go:108
            Error:          Not equal: 
                            expected: 400
                            actual  : 401
            Test:           TestPrivateRoutes
            Messages:       delete book without JWT and body
    private_routes_test.go:108: 
            Error Trace:    /home/ubuntu/Desktop/git/fix/fiber-go-template/pkg/routes/private_routes_test.go:108
            Error:          Not equal: 
                            expected: 404
                            actual  : 500
            Test:           TestPrivateRoutes
            Messages:       delete book with credentials
--- FAIL: TestPrivateRoutes (0.04s)

Both Redis and Postgres are running

stale[bot] commented 9 months ago

šŸ‘‹ Hello. Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Dhruv-Garg79 commented 6 months ago

I am facing the same issue, any update on this?