MCPcopy
hub / github.com/weaviate/weaviate / TestModule_Init_MissingHostname

Function TestModule_Init_MissingHostname

modules/usage-gcs/module_test.go:120–146  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

118}
119
120func TestModule_Init_MissingHostname(t *testing.T) {
121 // Set up environment for GCS bucket so it passes bucket validation
122 t.Setenv("USAGE_GCS_BUCKET", "test-bucket")
123 t.Setenv("CLUSTER_IN_LOCALHOST", "true")
124
125 mod := New()
126 logger := logrus.New()
127
128 testConfig := config.Config{
129 Cluster: cluster.Config{
130 Hostname: "", // Missing hostname
131 },
132 Usage: usagetypes.UsageConfig{
133 ScrapeInterval: runtime.NewDynamicValue(2 * time.Hour),
134 PolicyVersion: runtime.NewDynamicValue("2025-06-01"),
135 },
136 }
137
138 params := moduletools.NewMockModuleInitParams(t)
139 params.EXPECT().GetConfig().Return(&testConfig)
140 params.EXPECT().GetLogger().Return(logger)
141 params.EXPECT().GetMetricsRegisterer().Return(prometheus.NewPedanticRegistry())
142
143 err := mod.Init(context.Background(), params)
144 assert.Error(t, err)
145 assert.Contains(t, err.Error(), "cluster hostname is not set")
146}
147
148func TestModule_Init_InvalidScrapeInterval(t *testing.T) {
149 // Set up environment with invalid scrape interval

Callers

nothing calls this directly

Calls 12

EXPECTMethod · 0.95
NewDynamicValueFunction · 0.92
NewMockModuleInitParamsFunction · 0.92
NewFunction · 0.70
NewMethod · 0.65
GetConfigMethod · 0.65
GetLoggerMethod · 0.65
GetMetricsRegistererMethod · 0.65
InitMethod · 0.65
ContainsMethod · 0.65
ReturnMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…