-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathgraph_service_client_test.go
53 lines (42 loc) · 1.55 KB
/
graph_service_client_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
53
package tests
import (
"context"
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
msgraphsdkgo "github.com/microsoftgraph/msgraph-sdk-go"
"github.com/stretchr/testify/assert"
"testing"
)
func NewSimpleCredentials(token string) *SimpleCredentials {
return &SimpleCredentials{
TokenValue: token,
}
}
type SimpleCredentials struct {
TokenValue string
}
func (m *SimpleCredentials) GetToken(context.Context, policy.TokenRequestOptions) (azcore.AccessToken, error) {
return azcore.AccessToken{
Token: m.TokenValue,
}, nil
}
func TestNewGraphServiceClientWithCredentialsInitializesAClient(t *testing.T) {
cred := NewSimpleCredentials("asdasd")
client, _ := msgraphsdkgo.NewGraphServiceClientWithCredentials(cred, []string{"Files.Read"})
assert.NotNil(t, client)
}
func TestNewGraphServiceClientWithCredentialsAndHostsInitializesAClient(t *testing.T) {
cred := NewSimpleCredentials("asdasd")
client, _ := msgraphsdkgo.NewGraphServiceClientWithCredentialsAndHosts(cred, []string{"Files.Read"}, []string{"host1", "host2"})
assert.NotNil(t, client)
}
func TestClientAccessToGeneratedMethods(t *testing.T) {
cred := NewSimpleCredentials("asdasd")
client, _ := msgraphsdkgo.NewGraphServiceClientWithCredentials(cred, []string{"Files.Read"})
assert.NotNil(t, client.Groups())
}
func TestGetAdapterMethodThrowErrorOnNill(t *testing.T) {
cred := NewSimpleCredentials("asdasd")
client, _ := msgraphsdkgo.NewGraphServiceClientWithCredentials(cred, []string{"Files.Read"})
assert.NotNil(t, client.GetAdapter())
}