Skip to content
This repository has been archived by the owner on Apr 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #23 from websitesfortrello/tests
Browse files Browse the repository at this point in the history
adding tests with a real Trello board
  • Loading branch information
VojtechVitek committed Feb 24, 2016
2 parents 36cd0e2 + a7272a6 commit 4a7db23
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tests/env

*.swo
*.swp
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ sudo: false
language: go

go:
- 1.5.2
- 1.4.3
- 1.3
- 1.2
- tip

install:
- go build -race -v ./
- go get 'github.com/franela/goblin'
- go get 'github.com/onsi/gomega'
- go get 'github.com/VojtechVitek/go-trello'

script:
- go test -race ./tests/...
- go test ./tests/...
51 changes: 45 additions & 6 deletions tests/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,56 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package trello
package tests

import (
"os"
"testing"

"github.com/VojtechVitek/go-trello"

. "github.com/franela/goblin"
. "github.com/onsi/gomega"
)

func TestCreateTrelloClient(t *testing.T) {
_, err := trello.NewClient()
if err != nil {
t.Errorf("Failed to create Trello client.")
}
var Client *trello.Client
var Board *trello.Board
var err error

func TestManyThings(t *testing.T) {
g := Goblin(t)
RegisterFailHandler(func(m string, _ ...int) { g.Fail(m) })

g.Describe("many things", func() {
g.It("should create a client", func() {
key := os.Getenv("API_KEY")
token := os.Getenv("API_TOKEN")
Client, err = trello.NewAuthClient(key, &token)
Expect(err).To(BeNil())
})

g.It("should get a board", func() {
Board, err = Client.Board("iZVEfBeQ")
Expect(err).To(BeNil())
Expect(Board.Name).To(Equal("go-trello test board"))
})

g.It("should list the lists", func() {
lists, err := Board.Lists()
Expect(err).To(BeNil())
Expect(lists[0].Name).To(Equal("meta"))
Expect(lists[1].Name).To(Equal("a list"))
})

g.It("should get a card using two different methods", func() {
card, err := Board.Card("56cdb3e0f7f4609c2b6f15e4")
Expect(err).To(BeNil())
Expect(card.Name).To(Equal("a card"))
sameCard, err := Client.Card("8sB7wile")
Expect(err).To(BeNil())
Expect(sameCard.Name).To(Equal("a card"))
Expect(sameCard.Desc).To(Equal(card.Desc))
})
})

}

0 comments on commit 4a7db23

Please sign in to comment.