MCPcopy
hub / github.com/grafana/tempo / TestCreateHttpClient

Function TestCreateHttpClient

cmd/tempo-vulture/main_test.go:950–1008  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

948}
949
950func TestCreateHttpClient(t *testing.T) {
951 testCases := []struct {
952 name string
953 queryURL string
954 orgID string
955 queryLiveStores bool
956 expectedURL string
957 expectedOrgID string
958 expectedQLStores bool
959 }{
960 {
961 name: "QueryLiveStores set to true",
962 queryURL: "http://localhost:3200",
963 orgID: "test-org",
964 queryLiveStores: true,
965 expectedURL: "http://localhost:3200",
966 expectedOrgID: "test-org",
967 expectedQLStores: true,
968 },
969 {
970 name: "QueryLiveStores set to false",
971 queryURL: "http://localhost:3200",
972 orgID: "test-org",
973 queryLiveStores: false,
974 expectedURL: "http://localhost:3200",
975 expectedOrgID: "test-org",
976 expectedQLStores: false,
977 },
978 {
979 name: "QueryLiveStores true with empty orgID",
980 queryURL: "https://tempo.example.com",
981 orgID: "",
982 queryLiveStores: true,
983 expectedURL: "https://tempo.example.com",
984 expectedOrgID: "",
985 expectedQLStores: true,
986 },
987 {
988 name: "QueryLiveStores false with different URL",
989 queryURL: "https://grafana.com/tempo",
990 orgID: "prod-org",
991 queryLiveStores: false,
992 expectedURL: "https://grafana.com/tempo",
993 expectedOrgID: "prod-org",
994 expectedQLStores: false,
995 },
996 }
997
998 for _, tc := range testCases {
999 t.Run(tc.name, func(t *testing.T) {
1000 client := createHTTPClient(tc.queryURL, tc.orgID, tc.queryLiveStores)
1001
1002 assert.NotNil(t, client, "createHttpClient should return a non-nil client")
1003 assert.Equal(t, tc.expectedURL, client.BaseURL, "BaseURL should match expected value")
1004 assert.Equal(t, tc.expectedOrgID, client.OrgID, "OrgID should match expected value")
1005 assert.Equal(t, tc.expectedQLStores, client.QueryLiveStores, "QueryLiveStores should match expected value")
1006 })
1007 }

Callers

nothing calls this directly

Calls 3

createHTTPClientFunction · 0.70
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected