Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add cluster testing #100

Merged
merged 3 commits into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
language: go
go:
- '1.15'
- '1.16'
- '1.15'
- '1.16'
install:
- make install
- make install
script:
- make test
- make test
- if [[ "$TRAVIS_BRANCH" == "main" || "$TRAVIS_BRANCH" == "travis" ]] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
make cluster-test;
fi
notifications:
slack:
if: branch = main
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ install: githooks
go build -v ./...

test:
go test -v ./...
go test ./...

cluster-test:
go test --tags=cluster

goimports:
go get golang.org/x/tools/cmd/goimports
Expand Down
56 changes: 56 additions & 0 deletions cluster_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// +build cluster

package twilio

import (
"os"
"testing"

"github.com/stretchr/testify/assert"
openapi "github.com/twilio/twilio-go/rest/api/v2010"
)

var from string
var to string
var testClient *RestClient

func TestMain(m *testing.M) {
from = os.Getenv("TWILIO_FROM_NUMBER")
to = os.Getenv("TWILIO_TO_NUMBER")

testClient = NewRestClient()
ret := m.Run()
os.Exit(ret)
}

func TestSendingAText(t *testing.T) {
params := &openapi.CreateMessageParams{}
params.SetTo(to)
params.SetFrom(from)
params.SetBody("Hello there")

resp, err := testClient.ApiV2010.CreateMessage(params)
assert.Nil(t, err)
assert.NotNil(t, resp)
assert.Equal(t, "Hello there", *resp.Body)
assert.Equal(t, from, *resp.From)
assert.Equal(t, to, *resp.To)
}

func TestListingNumbers(t *testing.T) {
resp, err := testClient.ApiV2010.ListIncomingPhoneNumber(nil, 0)
assert.Nil(t, err)
assert.NotNil(t, resp)
assert.GreaterOrEqual(t, len(resp), 2)
eshanholtz marked this conversation as resolved.
Show resolved Hide resolved
}

func TestListingANumber(t *testing.T) {
params := &openapi.ListIncomingPhoneNumberParams{}
params.SetPhoneNumber(from)

resp, err := testClient.ApiV2010.ListIncomingPhoneNumber(params, 0)
assert.Nil(t, err)
assert.NotNil(t, resp)
assert.Equal(t, 1, len(resp))
assert.Equal(t, from, *resp[0].PhoneNumber)
}