Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
馃悰 Update handling of flags for Go 1.13+
Browse files Browse the repository at this point in the history
Go 1.13 introduces a Testing.Init function for handling test flags.

https://tip.golang.org/doc/go1.13#testing

This has the unfortunate consequence of panicking if flags are parsed
before testing.Init is called (for instance, in init). We therefore
update the code to parse flags in the Testing Main override such that
tests may be run in Go 1.11-1.14.

Related:
golang/go#31859

Co-authored-by: Andrew Pinkham <code@andrewsforge.com>

PR #3
[close ch1056]
  • Loading branch information
dericmiller committed May 11, 2020
1 parent 61260a6 commit 1593147
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
8 changes: 6 additions & 2 deletions .travis.yml
Expand Up @@ -4,12 +4,16 @@ branches:
- master
language: go
go:
- 1.11.4
- 1.11.13
- 1.12.17
- 1.13.10
- 1.14.2
install: true
sudo: required
services:
- docker
before_install:
- go get github.com/mattn/goveralls
script:
- goveralls -v -service=travis-ci
- go test -v -covermode=count -coverprofile=coverage.out
- goveralls -coverprofile=coverage.out -service=travis-ci
13 changes: 8 additions & 5 deletions integration_test.go
Expand Up @@ -13,15 +13,18 @@ var vaultRoleID, vaultSecretID, noKVRoleID, noKVSecretID string

var vaultVersion string

func init() {
flag.StringVar(&vaultVersion, "vaultVersion", "1.4.1", "provide vault version to be tested against")
flag.Parse()
}
func TestMain(m *testing.M) {

flag.StringVar(
&vaultVersion,
"vaultVersion",
"1.4.1",
"provide vault version to be tested against",
)
flag.Parse()
fmt.Println("Testing with Vault version", vaultVersion)
fmt.Println("TestMain: Preparing Vault server")
prepareVault()
fmt.Println("TestMain: Vault Prepared; Running Tests")
ret := m.Run()
os.Exit(ret)
}
Expand Down

0 comments on commit 1593147

Please sign in to comment.