Skip to content

Commit

Permalink
Create client_test.go
Browse files Browse the repository at this point in the history
Added test framework for client init
  • Loading branch information
ShocOne authored Jul 29, 2024
1 parent 84ffde9 commit e7750e2
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions internal/client/client_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package client

import (
"testing"

msgraphbetasdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
"github.com/stretchr/testify/assert"
)

// MockGraphServiceClient is a mock implementation of the GraphServiceClient for testing purposes.
type MockGraphServiceClient struct{}

// Ensure MockGraphServiceClient implements the necessary methods for both stable and beta clients.

func TestGraphClients(t *testing.T) {
stableClient := &MockGraphServiceClient{}
betaClient := &MockGraphServiceClient{}

clients := GraphClients{
StableClient: stableClient,
BetaClient: betaClient,
}

assert.NotNil(t, clients.StableClient, "StableClient should not be nil")
assert.NotNil(t, clients.BetaClient, "BetaClient should not be nil")

assert.Equal(t, stableClient, clients.StableClient, "StableClient should be set correctly")
assert.Equal(t, betaClient, clients.BetaClient, "BetaClient should be set correctly")
}

func TestGraphClientsInitialization(t *testing.T) {
stableClient := &msgraphsdk.GraphServiceClient{}
betaClient := &msgraphbetasdk.GraphServiceClient{}

clients := GraphClients{
StableClient: stableClient,
BetaClient: betaClient,
}

if clients.StableClient != stableClient {
t.Errorf("Expected StableClient to be %v, got %v", stableClient, clients.StableClient)
}

if clients.BetaClient != betaClient {
t.Errorf("Expected BetaClient to be %v, got %v", betaClient, clients.BetaClient)
}
}

0 comments on commit e7750e2

Please sign in to comment.