mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-02-09 13:36:56 +02:00
Merge pull request #171 from goreleaser/tests-docs
adding more tests and godocs
This commit is contained in:
commit
7a778d4eb9
3
Makefile
3
Makefile
@ -13,6 +13,9 @@ setup: ## Install all the build and lint dependencies
|
||||
test: ## Run all the tests
|
||||
gotestcover $(TEST_OPTIONS) -covermode=count -coverprofile=coverage.out $(SOURCE_FILES) -run $(TEST_PATTERN) -timeout=30s
|
||||
|
||||
cover: test ## RUn all the tests and opens the coverage report
|
||||
go tool cover -html=coverage.out
|
||||
|
||||
fmt: ## gofmt and goimports all go files
|
||||
find . -name '*.go' -not -wholename './vendor/*' | while read -r file; do gofmt -w -s "$$file"; goimports -w "$$file"; done
|
||||
|
||||
|
@ -13,6 +13,7 @@ We appreciate your contribution. Please refer to our [contributing guidelines](C
|
||||
[![Travis](https://img.shields.io/travis/goreleaser/goreleaser.svg?style=flat-square)](https://travis-ci.org/goreleaser/goreleaser)
|
||||
[![Coverage Status](https://img.shields.io/coveralls/goreleaser/goreleaser/master.svg?style=flat-square)](https://coveralls.io/github/goreleaser/goreleaser?branch=master)
|
||||
[![Go Report Card](https://goreportcard.com/badge/github.com/goreleaser/goreleaser?style=flat-square)](https://goreportcard.com/report/github.com/goreleaser/goreleaser)
|
||||
[![](https://godoc.org/github.com/goreleaser/goreleaser?status.svg&style=flat-square)](http://godoc.org/github.com/goreleaser/goreleaser)
|
||||
[![SayThanks.io](https://img.shields.io/badge/SayThanks.io-%E2%98%BC-1EAEDB.svg?style=flat-square)](https://saythanks.io/to/caarlos0)
|
||||
[![Powered By: GoReleaser](https://img.shields.io/badge/powered%20by-goreleaser-green.svg?style=flat-square)](https://github.com/goreleaser)
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// Package checksum contain algorithms to checksum files
|
||||
package checksum
|
||||
|
||||
import (
|
||||
|
@ -1,3 +1,4 @@
|
||||
// Package clients contains the client implementations for several providers.
|
||||
package clients
|
||||
|
||||
import (
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Package config contains the model and loader of the goreleaser configuration
|
||||
// file.
|
||||
package config
|
||||
|
||||
import (
|
||||
|
@ -1,3 +1,9 @@
|
||||
// Package context provides gorelease context which is passed through the
|
||||
// pipeline.
|
||||
//
|
||||
// The context extends the standard library context and add a few more
|
||||
// fields and other things, so pipes can gather data provided by previous
|
||||
// pipes without really knowing each other.
|
||||
package context
|
||||
|
||||
import (
|
||||
|
@ -1,3 +1,6 @@
|
||||
// Package archive implements the pipe interface with the intent of
|
||||
// archiving and compressing the binaries, readme, and other artifacts. It
|
||||
// also provides an Archive interface which represents an archiving format.
|
||||
package archive
|
||||
|
||||
import (
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Package tar implements the Archive interface providing tar.gz archiving
|
||||
// and compression.
|
||||
package tar
|
||||
|
||||
import (
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Package zip implements the Archive interface providing zip archiving
|
||||
// and compression.
|
||||
package zip
|
||||
|
||||
import (
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Package brew implements the Pipe, providing formula generation and
|
||||
// uploading it to a configured repo.
|
||||
package brew
|
||||
|
||||
import (
|
||||
|
@ -115,6 +115,34 @@ func TestRunPipe(t *testing.T) {
|
||||
assert.True(client.CreatedFile)
|
||||
}
|
||||
|
||||
func TestRunPipeBrewNotSetup(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
var ctx = &context.Context{
|
||||
Config: config.Project{
|
||||
Archive: config.Archive{
|
||||
Format: "tar.gz",
|
||||
},
|
||||
Brew: config.Homebrew{
|
||||
GitHub: config.Repo{
|
||||
Owner: "test",
|
||||
Name: "test",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
client := &DummyClient{}
|
||||
assert.Equal(ErrNoDarwin64Build, doRun(ctx, client))
|
||||
assert.False(client.CreatedFile)
|
||||
}
|
||||
|
||||
func TestRunPipeNoDarwinBuild(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
var ctx = &context.Context{}
|
||||
client := &DummyClient{}
|
||||
assert.NoError(doRun(ctx, client))
|
||||
assert.False(client.CreatedFile)
|
||||
}
|
||||
|
||||
type DummyClient struct {
|
||||
CreatedFile bool
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Package build implements Pipe and can build Go projects for
|
||||
// several platforms, with pre and post hook support.
|
||||
package build
|
||||
|
||||
import (
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Package checksums provides a Pipe that creates .checksums files for
|
||||
// each artifact.
|
||||
package checksums
|
||||
|
||||
import (
|
||||
|
@ -40,3 +40,16 @@ func TestPipe(t *testing.T) {
|
||||
assert.NoError(err)
|
||||
assert.Contains(string(bts), "61d034473102d7dac305902770471fd50f4c5b26f6831a56dd90b5184b3c30fc binary")
|
||||
}
|
||||
|
||||
func TestPipeFileNotExist(t *testing.T) {
|
||||
var assert = assert.New(t)
|
||||
folder, err := ioutil.TempDir("", "gorelasertest")
|
||||
assert.NoError(err)
|
||||
var ctx = &context.Context{
|
||||
Config: config.Project{
|
||||
Dist: folder,
|
||||
},
|
||||
}
|
||||
ctx.AddArtifact("nope")
|
||||
assert.Error(Pipe{}.Run(ctx))
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Package defaults implements the Pipe interface providing default values
|
||||
// for missing configuration.
|
||||
package defaults
|
||||
|
||||
import (
|
||||
|
@ -7,20 +7,20 @@ import (
|
||||
)
|
||||
|
||||
func TestRepoName(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
var assert = assert.New(t)
|
||||
repo, err := remoteRepo()
|
||||
assert.NoError(err)
|
||||
assert.Equal("goreleaser/goreleaser", repo.String())
|
||||
}
|
||||
|
||||
func TestExtractReporFromGitURL(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
var assert = assert.New(t)
|
||||
repo := extractRepoFromURL("git@github.com:goreleaser/goreleaser.git")
|
||||
assert.Equal("goreleaser/goreleaser", repo.String())
|
||||
}
|
||||
|
||||
func TestExtractReporFromHttpsURL(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
var assert = assert.New(t)
|
||||
repo := extractRepoFromURL("https://github.com/goreleaser/goreleaser.git")
|
||||
assert.Equal("goreleaser/goreleaser", repo.String())
|
||||
}
|
||||
|
2
pipeline/env/env.go
vendored
2
pipeline/env/env.go
vendored
@ -1,3 +1,5 @@
|
||||
// Package env implements the Pipe interface providing validation of
|
||||
// missing environment variables needed by the release process.
|
||||
package env
|
||||
|
||||
import (
|
||||
|
@ -1,3 +1,4 @@
|
||||
// Package fpm implements the Pipe interface providing FPM bindings.
|
||||
package fpm
|
||||
|
||||
import (
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Package git implements the Pipe interface extracting usefull data from
|
||||
// git and putting it in the context.
|
||||
package git
|
||||
|
||||
import (
|
||||
|
@ -1,3 +1,4 @@
|
||||
// Package pipeline provides a generic pipe interface.
|
||||
package pipeline
|
||||
|
||||
import "github.com/goreleaser/goreleaser/context"
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Package release implements Pipe and manages github releases and its
|
||||
// artifacts.
|
||||
package release
|
||||
|
||||
import (
|
||||
|
@ -47,6 +47,28 @@ func TestRunPipe(t *testing.T) {
|
||||
assert.True(client.UploadedFile)
|
||||
}
|
||||
|
||||
func TestRunPipeWithFileThatDontExist(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
var ctx = &context.Context{
|
||||
Git: context.GitInfo{
|
||||
CurrentTag: "v1.0.0",
|
||||
},
|
||||
Config: config.Project{
|
||||
Release: config.Release{
|
||||
GitHub: config.Repo{
|
||||
Owner: "test",
|
||||
Name: "test",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
ctx.AddArtifact("this-file-wont-exist-hopefuly")
|
||||
client := &DummyClient{}
|
||||
assert.Error(doRun(ctx, client))
|
||||
assert.True(client.CreatedRelease)
|
||||
assert.False(client.UploadedFile)
|
||||
}
|
||||
|
||||
type DummyClient struct {
|
||||
CreatedRelease bool
|
||||
UploadedFile bool
|
||||
|
Loading…
x
Reference in New Issue
Block a user