From 3bc428120da0346350f2c7db7864086f7f02dd3c Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 14 Apr 2017 15:39:32 -0300 Subject: [PATCH] adding more tests and godocs --- Makefile | 3 +++ README.md | 1 + checksum/checksum.go | 1 + clients/client.go | 1 + config/config.go | 2 ++ context/context.go | 6 ++++++ pipeline/archive/archive.go | 3 +++ pipeline/archive/tar/tar.go | 2 ++ pipeline/archive/zip/zip.go | 2 ++ pipeline/brew/brew.go | 2 ++ pipeline/build/build.go | 2 ++ pipeline/checksums/checksums.go | 2 ++ pipeline/checksums/checksums_test.go | 13 +++++++++++++ pipeline/defaults/defaults.go | 2 ++ pipeline/env/env.go | 2 ++ pipeline/fpm/fpm.go | 1 + pipeline/git/git.go | 2 ++ pipeline/pipe.go | 1 + pipeline/release/release.go | 2 ++ 19 files changed, 50 insertions(+) diff --git a/Makefile b/Makefile index cf9a6a736..bc6dedac7 100644 --- a/Makefile +++ b/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 diff --git a/README.md b/README.md index eb44a4024..223cd3d17 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/checksum/checksum.go b/checksum/checksum.go index 3a2fd1046..c85ba5016 100644 --- a/checksum/checksum.go +++ b/checksum/checksum.go @@ -1,3 +1,4 @@ +// Package checksum contain algorithms to checksum files package checksum import ( diff --git a/clients/client.go b/clients/client.go index 6d9c8f9e0..ab509c78b 100644 --- a/clients/client.go +++ b/clients/client.go @@ -1,3 +1,4 @@ +// Package clients contains the client implementations for several providers. package clients import ( diff --git a/config/config.go b/config/config.go index 641a497dd..5fb6554a7 100644 --- a/config/config.go +++ b/config/config.go @@ -1,3 +1,5 @@ +// Package config contains the model and loader of the goreleaser configuration +// file. package config import ( diff --git a/context/context.go b/context/context.go index c232a9f0b..2539cc3de 100644 --- a/context/context.go +++ b/context/context.go @@ -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 ( diff --git a/pipeline/archive/archive.go b/pipeline/archive/archive.go index 4dd5ccbdb..37223602d 100644 --- a/pipeline/archive/archive.go +++ b/pipeline/archive/archive.go @@ -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 ( diff --git a/pipeline/archive/tar/tar.go b/pipeline/archive/tar/tar.go index f99a27067..a9f907562 100644 --- a/pipeline/archive/tar/tar.go +++ b/pipeline/archive/tar/tar.go @@ -1,3 +1,5 @@ +// Package tar implements the Archive interface providing tar.gz archiving +// and compression. package tar import ( diff --git a/pipeline/archive/zip/zip.go b/pipeline/archive/zip/zip.go index 017d0166d..232f7dac6 100644 --- a/pipeline/archive/zip/zip.go +++ b/pipeline/archive/zip/zip.go @@ -1,3 +1,5 @@ +// Package zip implements the Archive interface providing zip archiving +// and compression. package zip import ( diff --git a/pipeline/brew/brew.go b/pipeline/brew/brew.go index 4d04399a9..e5893f737 100644 --- a/pipeline/brew/brew.go +++ b/pipeline/brew/brew.go @@ -1,3 +1,5 @@ +// Package brew implements the Pipe, providing formula generation and +// uploading it to a configured repo. package brew import ( diff --git a/pipeline/build/build.go b/pipeline/build/build.go index ee3f7ed93..0c135d1e6 100644 --- a/pipeline/build/build.go +++ b/pipeline/build/build.go @@ -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 ( diff --git a/pipeline/checksums/checksums.go b/pipeline/checksums/checksums.go index ea78b5442..4cae02fa5 100644 --- a/pipeline/checksums/checksums.go +++ b/pipeline/checksums/checksums.go @@ -1,3 +1,5 @@ +// Package checksums provides a Pipe that creates .checksums files for +// each artifact. package checksums import ( diff --git a/pipeline/checksums/checksums_test.go b/pipeline/checksums/checksums_test.go index 70db2f604..758df5e77 100644 --- a/pipeline/checksums/checksums_test.go +++ b/pipeline/checksums/checksums_test.go @@ -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)) +} diff --git a/pipeline/defaults/defaults.go b/pipeline/defaults/defaults.go index 0ec920174..266c66fc6 100644 --- a/pipeline/defaults/defaults.go +++ b/pipeline/defaults/defaults.go @@ -1,3 +1,5 @@ +// Package defaults implements the Pipe interface providing default values +// for missing configuration. package defaults import ( diff --git a/pipeline/env/env.go b/pipeline/env/env.go index f7f37abea..6f63dacd5 100644 --- a/pipeline/env/env.go +++ b/pipeline/env/env.go @@ -1,3 +1,5 @@ +// Package env implements the Pipe interface providing validation of +// missing environment variables needed by the release process. package env import ( diff --git a/pipeline/fpm/fpm.go b/pipeline/fpm/fpm.go index 4df33049f..74d8ef564 100644 --- a/pipeline/fpm/fpm.go +++ b/pipeline/fpm/fpm.go @@ -1,3 +1,4 @@ +// Package fpm implements the Pipe interface providing FPM bindings. package fpm import ( diff --git a/pipeline/git/git.go b/pipeline/git/git.go index 34b2434c5..9961e3a12 100644 --- a/pipeline/git/git.go +++ b/pipeline/git/git.go @@ -1,3 +1,5 @@ +// Package git implements the Pipe interface extracting usefull data from +// git and putting it in the context. package git import ( diff --git a/pipeline/pipe.go b/pipeline/pipe.go index d8196e870..d6ae9908c 100644 --- a/pipeline/pipe.go +++ b/pipeline/pipe.go @@ -1,3 +1,4 @@ +// Package pipeline provides a generic pipe interface. package pipeline import "github.com/goreleaser/goreleaser/context" diff --git a/pipeline/release/release.go b/pipeline/release/release.go index 3140eeb7e..bfd422bb1 100644 --- a/pipeline/release/release.go +++ b/pipeline/release/release.go @@ -1,3 +1,5 @@ +// Package release implements Pipe and manages github releases and its +// artifacts. package release import (