-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsense_test.go
46 lines (40 loc) · 837 Bytes
/
sense_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
package sense_test
import (
"context"
"log"
"testing"
"github.com/dnesting/sense"
)
func TestClient(t *testing.T) {
// TODO
}
func doSomethingWith(c *sense.Client) {}
func ExampleConnect() {
client, err := sense.Connect(
context.Background(),
sense.PasswordCredentials{
Email: "[email protected]",
Password: "secret",
})
if err != nil {
log.Fatal(err)
}
doSomethingWith(client)
}
func ExampleConnect_withMFA() {
mfaFunc := func(_ context.Context) (string, error) {
// obtain your MFA code somehow, we'll just use a fixed value to demonstrate
return "12345", nil
}
client, err := sense.Connect(
context.Background(),
sense.PasswordCredentials{
Email: "[email protected]",
Password: "secret",
MfaFn: mfaFunc, // <--
})
if err != nil {
log.Fatal(err)
}
doSomethingWith(client)
}