Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/pkgsite: tests don't pass on a clean clone #39598

Closed
mvdan opened this issue Jun 15, 2020 · 5 comments
Closed

x/pkgsite: tests don't pass on a clean clone #39598

mvdan opened this issue Jun 15, 2020 · 5 comments
Assignees
Labels
Milestone

Comments

@mvdan
Copy link
Member

@mvdan mvdan commented Jun 15, 2020

I see some failures about postgres not running, such as:

# golang.org/x/pkgsite/internal/middleware
internal/middleware/experiment_test.go:111:9: conversion from uint to string yields a string of one rune
2020/06/15 17:25:48 dial tcp [::1]:5432: connect: connection refused
FAIL	golang.org/x/pkgsite/internal/database	0.022s

Two options:

  1. Skip those tests if the connection is refused
  2. Use some sort of alternative without external dependencies, like a mock or an in-memory store implementation

The first is probably the best in the short term.

@mvdan mvdan added the pkgsite label Jun 15, 2020
@gopherbot gopherbot added this to the Unreleased milestone Jun 15, 2020
@julieqiu julieqiu added the NeedsFix label Jun 15, 2020
@jba
Copy link
Contributor

@jba jba commented Jun 15, 2020

Do you think running docker run -d -p 5432:5432 -e LANG=C postgres is too much to ask?

@bcmills
Copy link
Member

@bcmills bcmills commented Jun 16, 2020

In general I would expect go test ./... to pass at head within any golang.org/x module without needing to install or start any services that aren't already standard in the development environment.

(I agree with @mvdan: some sort of opt-in to the non-hermetic tests would probably be a good idea. Would it be reasonable for the test to start and stop its own database, perhaps as a subprocess, if one isn't already running and exec.LookPath finds a suitable version?)

@mvdan
Copy link
Member Author

@mvdan mvdan commented Jun 16, 2020

What @bcmills said. go test ./... should work on a clean clone of any Go module. For example, Go has plenty of tests that require special dependencies like git or gdb, and those are generally skipped when the tools aren't installed.

Documenting a way to run all tests the proper way is OK, but it shouldn't be a requirement to avoid failures :)

@jba jba self-assigned this Jun 16, 2020
@jba
Copy link
Contributor

@jba jba commented Jun 16, 2020

OK, I'll make it so.

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 16, 2020

Change https://golang.org/cl/238177 mentions this issue: internal: skip tests if no DB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants