Skip to content

tests/integration: Get rid of integration build constraint; skip tests instead. #560

@dmitshur

Description

@dmitshur

We're currently using a build constraint "integration" to prevent tests/integration from running when go test ./... happens in CI (and locally). This is because integration tests are heavier-weight and meant to be run explicitly. They need some environment variables with tokens to be set, etc.

// +build integration

The problem with that is that the code in that package is not included when one does go list ./... (as opposed to go list -tags=integration ./...), so doing things like go build ./..., go vet ./..., staticcheck ./..., doesn't catch issues. As a result, the integration tests tend to get build errors (forgetting to update APIs), miss out on lint/vet/staticcheck fixes, etc.

I suggest we get rid of the build constraint and instead rely on skipping tests when necessary integration environment variables are not set (perhaps rename them to be more specific to go-github integration tests, rather than more generic, to avoid false matches).

Some example of this being done in Go standard library are:

I don't see any downsides to doing that, are there any?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions