Skip to content

Commit

Permalink
fix: test setup issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Henkel committed Nov 21, 2024
1 parent 0968561 commit a24c7ca
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions e2e/fetcher_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import (
"github.com/prometheus/client_golang/prometheus/testutil"
)

const (
serverTypeName = "cx22"
)

var _ = Describe("For servers", Ordered, Label("servers"), func() {
sutServer := fetcher.NewServer(&fetcher.PriceProvider{Client: testClient}, "suite")
sutBackup := fetcher.NewServerBackup(&fetcher.PriceProvider{Client: testClient}, "suite")
Expand All @@ -20,7 +24,7 @@ var _ = Describe("For servers", Ordered, Label("servers"), func() {
location, _, err := testClient.Location.GetByName(ctx, "fsn1")
Expect(err).NotTo(HaveOccurred())

serverType, _, err := testClient.ServerType.GetByName(ctx, "cx22")
serverType, _, err := testClient.ServerType.GetByName(ctx, serverTypeName)
Expect(err).NotTo(HaveOccurred())

image, _, err := testClient.Image.GetByNameAndArchitecture(ctx, "ubuntu-24.04", hcloud.ArchitectureX86)
Expand Down Expand Up @@ -78,26 +82,26 @@ var _ = Describe("For servers", Ordered, Label("servers"), func() {

It("should get prices for correct values", func() {
By("Checking server prices")
Expect(testutil.ToFloat64(sutServer.GetHourly().WithLabelValues("test-server", "fsn1", "cx11", "e2e_suite_test"))).Should(BeNumerically(">", 0.0))
Expect(testutil.ToFloat64(sutServer.GetMonthly().WithLabelValues("test-server", "fsn1", "cx11", "e2e_suite_test"))).Should(BeNumerically(">", 0.0))
Expect(testutil.ToFloat64(sutServer.GetHourly().WithLabelValues("test-server", "fsn1", serverTypeName, "e2e_suite_test"))).Should(BeNumerically(">", 0.0))
Expect(testutil.ToFloat64(sutServer.GetMonthly().WithLabelValues("test-server", "fsn1", serverTypeName, "e2e_suite_test"))).Should(BeNumerically(">", 0.0))

By("Checking server backup prices")
Expect(testutil.ToFloat64(sutBackup.GetHourly().WithLabelValues("test-server", "fsn1", "cx11", "e2e_suite_test"))).Should(BeNumerically(">", 0.0))
Expect(testutil.ToFloat64(sutBackup.GetMonthly().WithLabelValues("test-server", "fsn1", "cx11", "e2e_suite_test"))).Should(BeNumerically(">", 0.0))
Expect(testutil.ToFloat64(sutBackup.GetHourly().WithLabelValues("test-server", "fsn1", serverTypeName, "e2e_suite_test"))).Should(BeNumerically(">", 0.0))
Expect(testutil.ToFloat64(sutBackup.GetMonthly().WithLabelValues("test-server", "fsn1", serverTypeName, "e2e_suite_test"))).Should(BeNumerically(">", 0.0))
})

It("should get zero for incorrect values", func() {
By("Checking server prices")
Expect(testutil.ToFloat64(sutServer.GetHourly().WithLabelValues("invalid-name", "fsn1", "cx11", "e2e_suite_test"))).Should(BeNumerically("==", 0))
Expect(testutil.ToFloat64(sutServer.GetHourly().WithLabelValues("test-server", "nbg1", "cx11", "e2e_suite_test"))).Should(BeNumerically("==", 0))
Expect(testutil.ToFloat64(sutServer.GetHourly().WithLabelValues("invalid-name", "fsn1", serverTypeName, "e2e_suite_test"))).Should(BeNumerically("==", 0))
Expect(testutil.ToFloat64(sutServer.GetHourly().WithLabelValues("test-server", "nbg1", serverTypeName, "e2e_suite_test"))).Should(BeNumerically("==", 0))
Expect(testutil.ToFloat64(sutServer.GetHourly().WithLabelValues("test-server", "fsn1", "cx21", "e2e_suite_test"))).Should(BeNumerically("==", 0))
Expect(testutil.ToFloat64(sutServer.GetHourly().WithLabelValues("test-server", "fsn1", "cx11", "e3e_suite_test"))).Should(BeNumerically("==", 0))
Expect(testutil.ToFloat64(sutServer.GetHourly().WithLabelValues("test-server", "fsn1", serverTypeName, "e3e_suite_test"))).Should(BeNumerically("==", 0))

By("Checking server backup prices")
Expect(testutil.ToFloat64(sutBackup.GetHourly().WithLabelValues("invalid-name", "fsn1", "cx11", "e2e_suite_test"))).Should(BeNumerically("==", 0))
Expect(testutil.ToFloat64(sutBackup.GetHourly().WithLabelValues("test-server", "nbg1", "cx11", "e2e_suite_test"))).Should(BeNumerically("==", 0))
Expect(testutil.ToFloat64(sutBackup.GetHourly().WithLabelValues("invalid-name", "fsn1", serverTypeName, "e2e_suite_test"))).Should(BeNumerically("==", 0))
Expect(testutil.ToFloat64(sutBackup.GetHourly().WithLabelValues("test-server", "nbg1", serverTypeName, "e2e_suite_test"))).Should(BeNumerically("==", 0))
Expect(testutil.ToFloat64(sutBackup.GetHourly().WithLabelValues("test-server", "fsn1", "cx21", "e2e_suite_test"))).Should(BeNumerically("==", 0))
Expect(testutil.ToFloat64(sutBackup.GetHourly().WithLabelValues("test-server", "fsn1", "cx11", "e3e_suite_test"))).Should(BeNumerically("==", 0))
Expect(testutil.ToFloat64(sutBackup.GetHourly().WithLabelValues("test-server", "fsn1", serverTypeName, "e3e_suite_test"))).Should(BeNumerically("==", 0))
})
})
})

0 comments on commit a24c7ca

Please sign in to comment.