Skip to main content
Glama

DataDog MCP Server

by Believe-SA
client_test.go1.99 kB
// internal/client/client_test.go package client import ( "os" "testing" ) func TestNewDataDogClient(t *testing.T) { // Test client creation with environment variables apiKey := "test-api-key-12345678901234567890123456789012" site := "datadoghq.eu" // Set environment variables for testing os.Setenv("DD_API_KEY", apiKey) os.Setenv("DATADOG_SITE", site) defer os.Unsetenv("DD_API_KEY") defer os.Unsetenv("DATADOG_SITE") client, err := NewDataDogClient(apiKey, site) if err != nil { t.Fatalf("Failed to create DataDog client: %v", err) } if client == nil { t.Fatal("Expected client to be created, got nil") } if client.Site != site { t.Errorf("Expected site to be '%s', got '%s'", site, client.Site) } if client.Client == nil { t.Fatal("Expected client.Client to be initialized, got nil") } } func TestNewDataDogClientWithAppKey(t *testing.T) { // Test client creation with application key apiKey := "test-api-key-12345678901234567890123456789012" appKey := "test-app-key-12345678901234567890123456789012" site := "datadoghq.eu" // Set environment variables for testing os.Setenv("DD_API_KEY", apiKey) os.Setenv("DATADOG_APP_KEY", appKey) os.Setenv("DATADOG_SITE", site) defer os.Unsetenv("DD_API_KEY") defer os.Unsetenv("DATADOG_APP_KEY") defer os.Unsetenv("DATADOG_SITE") client, err := NewDataDogClient(apiKey, site) if err != nil { t.Fatalf("Failed to create DataDog client: %v", err) } if client == nil { t.Fatal("Expected client to be created, got nil") } if client.Site != site { t.Errorf("Expected site to be '%s', got '%s'", site, client.Site) } } func TestMinFunction(t *testing.T) { // Test the min helper function tests := []struct { a, b, expected int }{ {1, 2, 1}, {2, 1, 1}, {5, 5, 5}, {0, 10, 0}, {-1, 1, -1}, } for _, test := range tests { result := min(test.a, test.b) if result != test.expected { t.Errorf("min(%d, %d) = %d, expected %d", test.a, test.b, result, test.expected) } } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Believe-SA/datadog-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server