-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemployee_test.go
52 lines (40 loc) · 1.16 KB
/
employee_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package gomts_test
import (
"context"
"math/rand"
"testing"
"github.com/stretchr/testify/assert"
"go.charbar.io/gomts"
)
var numRunes = []rune("1234567890")
func randomPin() string {
b := make([]rune, 4)
for i := range b {
b[i] = numRunes[rand.Intn(len(numRunes))]
}
return string(b)
}
func TestEmployeesCreate(t *testing.T) {
client, _ := integrationTest(t)
ctx := context.Background()
dept, err := client.Departments().Create(ctx, &gomts.DepartmentCreateRequest{
Name: testResourceName("something"),
})
assert.NoError(t, err)
createRequest := &gomts.EmployeeCreateRequest{
Name: testResourceName("bob ross"),
PIN: randomPin(),
Title: "Senior Artist",
DepartmentID: dept.ID,
}
newEmployee, err := client.Employees().Create(ctx, createRequest)
assert.NoError(t, err)
employee, err := client.Employees().Get(ctx, newEmployee.ID)
assert.NoError(t, err)
assert.Equal(t, createRequest.Name, employee.Name)
assert.Equal(t, createRequest.PIN, employee.PIN)
assert.Equal(t, createRequest.Title, employee.Title)
assert.NotEmpty(t, employee.CardNumber)
assert.NotEmpty(t, employee.CardQRCode)
assert.NotEmpty(t, employee.PrimaryDepartment)
}