Skip to content

Commit

Permalink
Update usage of go-tfl library
Browse files Browse the repository at this point in the history
Now the caller provides the `*http.Client` (timeout set to 5 seconds)
  • Loading branch information
thoeni committed Sep 5, 2017
1 parent 21ed38c commit ee9b4dd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
16 changes: 8 additions & 8 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@
version = "1.1.4"

[[constraint]]
branch = "master"
name = "github.com/thoeni/go-tfl"
version = "v1.0.0"
15 changes: 8 additions & 7 deletions http_handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ package main
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"testing"

"github.com/golang/mock/gomock"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"github.com/thoeni/go-tfl"
"github.com/thoeni/slack-tube-service/mocks"
"io/ioutil"
"net/http"
"net/http/httptest"
"testing"
)

const (
Expand Down Expand Up @@ -112,7 +113,7 @@ func TestLineStatusHandler_Integration_HappyPathAllLines(t *testing.T) {
}))
defer ts.Close()

cachedTflClient := tfl.NewCachedClient(120)
cachedTflClient := tfl.NewCachedClient(http.DefaultClient, 120)
cachedTflClient.SetBaseURL(ts.URL + "/")
tubeService = TubeService{cachedTflClient}

Expand All @@ -137,10 +138,10 @@ func TestLineStatusHandler_Integration_HappyPathSingleLine(t *testing.T) {
}))
defer ts.Close()

client := tfl.NewClient()
client := tfl.NewClient(http.DefaultClient)
client.SetBaseURL(ts.URL + "/")

cachedTflClient := tfl.NewCachedClient(120)
cachedTflClient := tfl.NewCachedClient(http.DefaultClient, 120)
cachedTflClient.SetBaseURL(ts.URL + "/")
tubeService = TubeService{cachedTflClient}

Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

"flag"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/dynamodb"
Expand Down Expand Up @@ -57,7 +58,10 @@ var (
)
)

var tubeService TflService = TubeService{tfl.NewCachedClient(120)}
var httpTimeout = 5 * time.Second
var tubeService TflService = TubeService{
tfl.NewCachedClient(&http.Client{Timeout: httpTimeout}, 120),
}

func initialise() {

Expand Down

0 comments on commit ee9b4dd

Please sign in to comment.