fix travis tests

This commit is contained in:
Jimmy Zelinskie 2013-08-29 00:24:31 -04:00
parent ecbedf4b89
commit 6e7d6f1a31
3 changed files with 33 additions and 8 deletions

View file

@ -2,6 +2,9 @@ language: go
go: 1.1.2
env:
- TRAVISCONFIGPATH=/home/travis/gopath/src/github.com/pushrax/chihaya/config/example.json
services:
- redis-server

View file

@ -11,14 +11,21 @@ import (
"testing"
)
func getConfigPath() string {
if os.Getenv("TRAVISCONFIGPATH") != "" {
return os.Getenv("TRAVISCONFIGPATH")
}
return os.ExpandEnv("$GOPATH/src/github.com/pushrax/chihaya/config/example.json")
}
func TestOpenConfig(t *testing.T) {
if _, err := Open(os.ExpandEnv("$GOPATH/src/github.com/pushrax/chihaya/config/example.json")); err != nil {
if _, err := Open(getConfigPath()); err != nil {
t.Error(err)
}
}
func TestNewConfig(t *testing.T) {
contents, err := ioutil.ReadFile(os.ExpandEnv("$GOPATH/src/github.com/pushrax/chihaya/config/example.json"))
contents, err := ioutil.ReadFile(getConfigPath())
if err != nil {
t.Error(err)
}

View file

@ -6,7 +6,6 @@ package server
import (
"errors"
"fmt"
"net/http"
"net/http/httptest"
"os"
@ -18,13 +17,29 @@ import (
_ "github.com/pushrax/chihaya/storage/batter"
)
func TestStats(t *testing.T) {
testConfig, err := config.Open(os.ExpandEnv("$GOPATH/src/github.com/pushrax/chihaya/config/example.json"))
if err != nil {
t.Error(err)
func NewServer() (*Server, error) {
var path string
if os.Getenv("TRAVISCONFIGPATH") != "" {
path = os.Getenv("TRAVISCONFIGPATH")
} else {
path = os.ExpandEnv("$GOPATH/src/github.com/pushrax/chihaya/config/example.json")
}
fmt.Println(testConfig)
testConfig, err := config.Open(path)
if err != nil {
return nil, err
}
s, err := New(testConfig)
if err != nil {
return nil, err
}
return s, nil
}
func TestStats(t *testing.T) {
s, err := NewServer()
if err != nil {
t.Error(err)
}