Skip to content

Commit

Permalink
codecov: added (#62)
Browse files Browse the repository at this point in the history
Also updated the build to correctly check if the generated files are in sync.
  • Loading branch information
elliotchance authored Apr 28, 2019
1 parent a1ae87f commit 7393722
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ script:
- $(exit $(go fmt ./... | grep -v /vendor/ | wc -l))

# Make sure go generate is in sync.
- go generate ./...
- go generate ./... && go install && go generate ./...
- $(exit $(git status --porcelain | wc -l))

# Run tests.
- go test -race ./...
- go test -race ./pie -coverprofile=coverage.txt -covermode=atomic

after_success:
- bash <(curl -s https://codecov.io/bash)
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 🍕 `github.com/elliotchance/pie`
[![GoDoc](https://godoc.org/github.com/elliotchance/pie?status.svg)](https://godoc.org/github.com/elliotchance/pie)
[![Build Status](https://travis-ci.org/elliotchance/pie.svg?branch=master)](https://travis-ci.org/elliotchance/pie)
[![codecov](https://codecov.io/gh/elliotchance/pie/branch/master/graph/badge.svg)](https://codecov.io/gh/elliotchance/pie)

**Enjoy a slice!** `pie` is a code generator for dealing with slices that
focuses on type safety, performance and immutability.
Expand Down
18 changes: 18 additions & 0 deletions pie/myints_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package pie

import (
"github.com/stretchr/testify/assert"
"testing"
)

// There tests are just to make sure that the select functions for myInts are
// generated. The more extensive tests for these functions are in ints_test.go

func TestMyInts_Average(t *testing.T) {
assert.Equal(t, 0.0, myInts(nil).Average())
assert.Equal(t, 4.333333333333333, myInts{1, 5, 7}.Average())
}

func TestMyInts_Sum(t *testing.T) {
assert.Equal(t, 13, myInts{1, 5, 7}.Sum())
}

0 comments on commit 7393722

Please sign in to comment.