1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-26 04:22:05 +02:00

test: remove bucket after test

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This commit is contained in:
Carlos Alexandro Becker 2021-09-22 01:18:45 -03:00
parent ad7df518b6
commit 722343125a
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
3 changed files with 65 additions and 15 deletions

35
Taskfile.yml Normal file
View File

@ -0,0 +1,35 @@
version: '3'
tasks:
dev:
cmds:
- cp -f scripts/pre-commit.sh .git/hooks/pre-commit
setup:
cmds:
- go mod tidy
fmt:
cmds:
- gofumpt -w -s -l .
test:
vars:
TEST_OPTIONS: ''
TEST_PATTERN: '.'
SOURCE_FILES: './...'
env:
LC_ALL: C
cmds:
- 'go test {{.TEST_OPTIONS}} -failfast -race -coverpkg={{.SOURCE_FILES}} -covermode=atomic -coverprofile=coverage.txt {{.SOURCE_FILES}} -timeout=5m -run {{.TEST_PATTERN}}'
cover:
deps: [test]
cmds:
- go tool cover -html=coverage.txt
serve:
vars:
DOCKER: docker
cmds:
- '{{.DOCKER}} run --rm -it -p 8000:8000 -v $PWD/www:/docs docker.io/squidfunk/mkdocs-material'

View File

@ -23,9 +23,8 @@ import (
)
const (
minioUser = "minio"
minioPwd = "miniostorage"
testBucket = "test"
minioUser = "minio"
minioPwd = "miniostorage"
)
func TestMinioUpload(t *testing.T) {
@ -45,7 +44,7 @@ func TestMinioUpload(t *testing.T) {
Blobs: []config.Blob{
{
Provider: "s3",
Bucket: testBucket,
Bucket: "test",
Region: "us-east",
Endpoint: "http://" + listen,
IDs: []string{"foo", "bar"},
@ -147,7 +146,7 @@ func TestMinioUploadRootFolder(t *testing.T) {
Blobs: []config.Blob{
{
Provider: "s3",
Bucket: testBucket,
Bucket: "test",
Folder: "/",
Endpoint: "http://" + listen,
},
@ -223,11 +222,6 @@ func prepareEnv() {
func start(tb testing.TB, name, listen string) {
tb.Helper()
tb.Cleanup(func() {
if out, err := exec.Command("docker", "stop", name).CombinedOutput(); err != nil {
tb.Fatalf("failed to stop minio: %s", string(out))
}
})
if out, err := exec.Command(
"docker", "run", "-d", "--rm",
@ -256,17 +250,27 @@ func start(tb testing.TB, name, listen string) {
tb.Log("waiting for minio to be healthy")
}
mc(tb, name, "mc mb local/test")
tb.Cleanup(func() {
mc(tb, name, "mc rb --force local/test")
if out, err := exec.Command("docker", "stop", name).CombinedOutput(); err != nil {
tb.Fatalf("failed to stop minio: %s", string(out))
}
})
}
func mc(tb testing.TB, name, cmd string) {
tb.Helper()
if out, err := exec.Command(
"docker", "run", "--rm",
"--link", name,
"--entrypoint", "sh",
"minio/mc",
"-c", fmt.Sprintf(
"mc config host add local http://%s:9000 %s %s; mc mb local/%s",
name,
minioUser,
minioPwd,
testBucket,
"mc config host add local http://%s:9000 %s %s; %s",
name, minioUser, minioPwd, cmd,
),
).CombinedOutput(); err != nil {
tb.Fatalf("failed to create test bucket: %s", string(out))

11
test.yml Normal file
View File

@ -0,0 +1,11 @@
# This is an example .goreleaser.yml file with some sane defaults.
# Make sure to check the documentation at https://goreleaser.com
builds:
- env:
- CGO_ENABLED=0
goos: [darwin]
goarch: [amd64]
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"