(t *testing.T)
| 118 | } |
| 119 | |
| 120 | func 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 | |
| 148 | func TestModule_Init_InvalidScrapeInterval(t *testing.T) { |
| 149 | // Set up environment with invalid scrape interval |
nothing calls this directly
no test coverage detected
searching dependent graphs…