forked from MEDIGO/go-zendesk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testing.go
52 lines (41 loc) · 1.03 KB
/
testing.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 zendesk
import (
"crypto/rand"
"encoding/hex"
"testing"
"github.com/stretchr/testify/require"
)
func randString(l int) string {
b := make([]byte, l)
rand.Read(b)
return hex.EncodeToString(b)[:l]
}
func randUser(t *testing.T, client Client) *User {
input := &User{
Name: String("Testy Testacular"),
Email: String(randString(16) + "@example.com"),
}
user, err := client.CreateUser(input)
require.NoError(t, err)
return user
}
func randOrg(t *testing.T, client Client) *Organization {
input := &Organization{
Name: String("Very Fake Clinic - " + randString(16)),
}
org, err := client.CreateOrganization(input)
require.NoError(t, err)
return org
}
func randTicket(t *testing.T, client Client, user *User) *Ticket {
input := &Ticket{
Subject: String("My printer is on fire!"),
Description: String("The smoke is very colorful."),
RequesterID: user.ID,
Type: String("problem"),
Tags: []string{"test"},
}
ticket, err := client.CreateTicket(input)
require.NoError(t, err)
return ticket
}