updating READMD.md

pull/1/merge
jackspirou 9 years ago
parent e456f88f0f
commit 618f60fd11

@ -1,6 +1,6 @@
# drone-with-go [![Build Status](http://beta.drone.io/api/badges/drone-demos/drone-with-go/status.svg)](http://beta.drone.io/drone-demos/drone-with-go) [![Build Status](https://aircover.co/badges/drone-demos/drone-with-go/coverage.svg)](https://aircover.co/drone-demos/drone-with-go) # drone-with-go [![Build Status](http://beta.drone.io/api/badges/drone-demos/drone-with-go/status.svg)](http://beta.drone.io/drone-demos/drone-with-go) [![Build Status](https://aircover.co/badges/drone-demos/drone-with-go/coverage.svg)](https://aircover.co/drone-demos/drone-with-go)
An example of how to test Go code. An example of how to test Go code with Drone.
# Basic Testing # Basic Testing
To run basic CI tests use the following in your `.drone.yml` file. To run basic CI tests use the following in your `.drone.yml` file.
@ -12,11 +12,15 @@ build:
- go test ./... - go test ./...
``` ```
In this config `image: golang:1.5.3` references the official Golang Docker image hosted on the Docker Hub registry at https://hub.docker.com/r/_/golang/.
Go tests are execute with the `go test ./...` command.
# Advanced Testing # Advanced Testing
## Environment Variables
Using environment variables to configure Go testing is easy. Using environment variables to configure Go testing is easy.
Configure environment variables by setting the `build` section's `environment`. Configure environment variables by setting the `build` section's `environment`.
`.drone.yml`:
```yaml ```yaml
build: build:
image: golang:1.5.3 image: golang:1.5.3
@ -29,10 +33,33 @@ build:
- go test ./... - go test ./...
``` ```
Below is a more advanced `.drone.yml` for notification integrations like HipChat. ## Coverage
Drone tests work best with the coverage plugin and the [aircover.co](https://aircover.co) service.
We only want to send a coverage report when all tests pass, so the coverage plugin uses `publish`.
Also, we should specify a particular branch so that coverage reports are consistent.
```yaml ```yaml
build:
image: golang:1.5.3
environment:
- GO15VENDOREXPERIMENT=1
- GOOS=linux
- GOARCH=amd64
- CGO_ENABLED=0
commands:
- go test -cover -coverprofile coverage.out
publish:
coverage:
when:
branch: master
```
## Plugins
Notification plugins use `notify` for integrations like HipChat.
You can find a list of plugins at [readme.drone.io/plugins](http://readme.drone.io/plugins/).
```yaml
build: build:
image: golang:1.5.3 image: golang:1.5.3
environment: environment:
@ -40,9 +67,13 @@ build:
- GOOS=linux - GOOS=linux
- GOARCH=amd64 - GOARCH=amd64
- CGO_ENABLED=0 - CGO_ENABLED=0
- COVERALLS_TOKEN=$$COVERALLS_TOKEN
commands: commands:
- go test -cover ./... - go test -cover -coverprofile coverage.out
publish:
coverage:
when:
branch: master
notify: notify:
hipchat: hipchat:

@ -1,6 +1,13 @@
package main package main
import "testing" import (
"os"
"testing"
)
func TestMain(m *testing.M) {
os.Exit(m.Run())
}
func TestHelloWorld(t *testing.T) { func TestHelloWorld(t *testing.T) {
if HelloWorld() != "hello world" { if HelloWorld() != "hello world" {

Loading…
Cancel
Save