Skip to content
This repository has been archived by the owner on Oct 21, 2019. It is now read-only.

Commit

Permalink
Add basic member tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bobheadxi committed Jun 17, 2018
1 parent 6b32481 commit 6a6a9c9
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions data/member_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package data

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/ubclaunchpad/rocket/model"
)

func TestMemberCreateGetUpdateRemove(t *testing.T) {
dal := newTestDBConnection()
defer dal.Close()

// Create a new member
member := &model.Member{
SlackID: "1234",
Name: "Big Bruno",
}
err := dal.CreateMember(member)
assert.Nil(t, err)

// Get existing member
memberGet := &model.Member{SlackID: "1234"}
err = dal.GetMemberBySlackID(memberGet)
assert.Nil(t, err)
assert.Equal(t, member.Name, memberGet.Name)

// Update existing member
memberUpdated := &model.Member{
SlackID: "1234",
Name: "Little Bruno",
Position: "A REAL GUY",
}
err = dal.UpdateMember(memberUpdated)
assert.Nil(t, err)
err = dal.GetMemberBySlackID(memberGet)
assert.Nil(t, err)
assert.Equal(t, memberUpdated.Name, memberGet.Name)
assert.Equal(t, memberUpdated.Position, memberGet.Position)

// Delete existing member
err = dal.DeleteMember(&model.Member{SlackID: "1234"})
assert.Nil(t, err)
err = dal.GetMemberBySlackID(&model.Member{SlackID: "1234"})
assert.NotNil(t, err)
}

0 comments on commit 6a6a9c9

Please sign in to comment.