|
5 | 5 |
|
6 | 6 | . "github.com/onsi/ginkgo/v2" |
7 | 7 | . "github.com/onsi/gomega" |
| 8 | + |
| 9 | + "math" |
8 | 10 | ) |
9 | 11 |
|
10 | 12 | var _ = Describe("FactoryBuildingCollector", func() { |
@@ -139,5 +141,152 @@ var _ = Describe("FactoryBuildingCollector", func() { |
139 | 141 | Expect(ironNothing).To(Equal(float64(0.25))) |
140 | 142 | }) |
141 | 143 | }) |
| 144 | + |
| 145 | + Describe("with power particle accelerator making diamonds", func() { |
| 146 | + BeforeEach(func() { |
| 147 | + FRMServer.Reset() |
| 148 | + url = FRMServer.server.URL |
| 149 | + collector = exporter.NewFactoryBuildingCollector("/getFactory") |
| 150 | + |
| 151 | + FRMServer.ReturnsFactoryBuildings([]exporter.BuildingDetail{ |
| 152 | + { |
| 153 | + Building: "Particle Accelerator", |
| 154 | + Recipe: "Diamonds", |
| 155 | + ManuSpeed: 100.0, |
| 156 | + CircuitGroupId: 0, |
| 157 | + PowerInfo: exporter.PowerInfo{ |
| 158 | + CircuitGroupId: 1, |
| 159 | + PowerConsumed: 23, |
| 160 | + // value will be ignored for this - the recipe here is set to 750 in power_info.go |
| 161 | + MaxPowerConsumed: 4, |
| 162 | + }, |
| 163 | + }, |
| 164 | + }) |
| 165 | + }) |
| 166 | + It("recalculates max power use", func() { |
| 167 | + collector.Collect(url, sessionName) |
| 168 | + |
| 169 | + val, err := gaugeValue(exporter.FactoryPowerMax, "1", url, sessionName) |
| 170 | + Expect(err).ToNot(HaveOccurred()) |
| 171 | + Expect(val).To(Equal(750.0)) |
| 172 | + }) |
| 173 | + }) |
| 174 | + Describe("with an overclocked accelerator", func() { |
| 175 | + BeforeEach(func() { |
| 176 | + FRMServer.Reset() |
| 177 | + url = FRMServer.server.URL |
| 178 | + collector = exporter.NewFactoryBuildingCollector("/getFactory") |
| 179 | + |
| 180 | + FRMServer.ReturnsFactoryBuildings([]exporter.BuildingDetail{ |
| 181 | + { |
| 182 | + Building: "Particle Accelerator", |
| 183 | + Recipe: "Nuclear Pasta", |
| 184 | + ManuSpeed: 250.0, |
| 185 | + CircuitGroupId: 0, |
| 186 | + PowerInfo: exporter.PowerInfo{ |
| 187 | + CircuitGroupId: 1, |
| 188 | + PowerConsumed: 23, |
| 189 | + // value will be ignored for this - the recipe here is set to 750 in power_info.go |
| 190 | + MaxPowerConsumed: 4, |
| 191 | + }, |
| 192 | + }, |
| 193 | + }) |
| 194 | + }) |
| 195 | + It("recalculates max power use", func() { |
| 196 | + collector.Collect(url, sessionName) |
| 197 | + |
| 198 | + val, err := gaugeValue(exporter.FactoryPowerMax, "1", url, sessionName) |
| 199 | + Expect(err).ToNot(HaveOccurred()) |
| 200 | + Expect(val).To(Equal(math.Pow((250.0/100), exporter.ClockspeedExponent) * 1500.0)) |
| 201 | + }) |
| 202 | + }) |
| 203 | + Describe("with an underclocked converter", func() { |
| 204 | + BeforeEach(func() { |
| 205 | + FRMServer.Reset() |
| 206 | + url = FRMServer.server.URL |
| 207 | + collector = exporter.NewFactoryBuildingCollector("/getFactory") |
| 208 | + |
| 209 | + FRMServer.ReturnsFactoryBuildings([]exporter.BuildingDetail{ |
| 210 | + { |
| 211 | + Building: "Converter", |
| 212 | + Recipe: "Coal", |
| 213 | + ManuSpeed: 50.0, |
| 214 | + CircuitGroupId: 0, |
| 215 | + PowerInfo: exporter.PowerInfo{ |
| 216 | + CircuitGroupId: 1, |
| 217 | + PowerConsumed: 23, |
| 218 | + // value will be ignored for this - the recipe here is set to 400 * clockspeed in power_info.go |
| 219 | + MaxPowerConsumed: 4, |
| 220 | + }, |
| 221 | + }, |
| 222 | + }) |
| 223 | + }) |
| 224 | + It("recalculates max power use", func() { |
| 225 | + collector.Collect(url, sessionName) |
| 226 | + |
| 227 | + val, err := gaugeValue(exporter.FactoryPowerMax, "1", url, sessionName) |
| 228 | + Expect(err).ToNot(HaveOccurred()) |
| 229 | + Expect(val).To(Equal(math.Pow((50.0/100), exporter.ClockspeedExponent) * 400.0)) |
| 230 | + }) |
| 231 | + }) |
| 232 | + Describe("with an overclocked quantum encoder", func() { |
| 233 | + BeforeEach(func() { |
| 234 | + FRMServer.Reset() |
| 235 | + url = FRMServer.server.URL |
| 236 | + collector = exporter.NewFactoryBuildingCollector("/getFactory") |
| 237 | + |
| 238 | + FRMServer.ReturnsFactoryBuildings([]exporter.BuildingDetail{ |
| 239 | + { |
| 240 | + Building: "Quantum Encoder", |
| 241 | + Recipe: "Power Shard", |
| 242 | + ManuSpeed: 250.0, |
| 243 | + CircuitGroupId: 0, |
| 244 | + PowerInfo: exporter.PowerInfo{ |
| 245 | + CircuitGroupId: 1, |
| 246 | + PowerConsumed: 23, |
| 247 | + // value will be ignored for this - the recipe here is set to 2000 * clockspeed in power_info.go |
| 248 | + MaxPowerConsumed: 4, |
| 249 | + }, |
| 250 | + }, |
| 251 | + }) |
| 252 | + }) |
| 253 | + It("recalculates max power use", func() { |
| 254 | + collector.Collect(url, sessionName) |
| 255 | + |
| 256 | + val, err := gaugeValue(exporter.FactoryPowerMax, "1", url, sessionName) |
| 257 | + Expect(err).ToNot(HaveOccurred()) |
| 258 | + Expect(val).To(Equal(math.Pow((250.0/100), exporter.ClockspeedExponent) * 2000.0)) |
| 259 | + }) |
| 260 | + }) |
| 261 | + Describe("with a somerslooped quantum encoder", func() { |
| 262 | + BeforeEach(func() { |
| 263 | + FRMServer.Reset() |
| 264 | + url = FRMServer.server.URL |
| 265 | + collector = exporter.NewFactoryBuildingCollector("/getFactory") |
| 266 | + |
| 267 | + FRMServer.ReturnsFactoryBuildings([]exporter.BuildingDetail{ |
| 268 | + { |
| 269 | + Building: "Quantum Encoder", |
| 270 | + Recipe: "Power Shard", |
| 271 | + ManuSpeed: 100.0, |
| 272 | + CircuitGroupId: 0, |
| 273 | + Somersloops: 4, |
| 274 | + PowerInfo: exporter.PowerInfo{ |
| 275 | + CircuitGroupId: 1, |
| 276 | + PowerConsumed: 23, |
| 277 | + // value will be ignored for this - the recipe here is set to 2000 * clockspeed in power_info.go |
| 278 | + MaxPowerConsumed: 4, |
| 279 | + }, |
| 280 | + }, |
| 281 | + }) |
| 282 | + }) |
| 283 | + It("recalculates max power use", func() { |
| 284 | + collector.Collect(url, sessionName) |
| 285 | + |
| 286 | + val, err := gaugeValue(exporter.FactoryPowerMax, "1", url, sessionName) |
| 287 | + Expect(err).ToNot(HaveOccurred()) |
| 288 | + Expect(val).To(Equal(4 * 2000.0)) |
| 289 | + }) |
| 290 | + }) |
142 | 291 | }) |
143 | 292 | }) |
0 commit comments