|
|
@@ -4,6 +4,7 @@ import (
|
|
|
"fmt"
|
|
|
"math"
|
|
|
"os"
|
|
|
+ "strconv"
|
|
|
"strings"
|
|
|
"testing"
|
|
|
"time"
|
|
|
@@ -119,8 +120,10 @@ func TestPVPriceFromCSV(t *testing.T) {
|
|
|
t.Errorf("Error in NodePricing: %s", err.Error())
|
|
|
} else {
|
|
|
gotPrice := resPV.Cost
|
|
|
- if gotPrice != wantPrice {
|
|
|
- t.Errorf("Wanted price '%s' got price '%s'", wantPrice, gotPrice)
|
|
|
+ wantPriceFloat, _ := strconv.ParseFloat(wantPrice, 64)
|
|
|
+ gotPriceFloat, _ := strconv.ParseFloat(gotPrice, 64)
|
|
|
+ if gotPriceFloat != wantPriceFloat {
|
|
|
+ t.Errorf("Wanted price '%f' got price '%f'", wantPriceFloat, gotPriceFloat)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -151,8 +154,10 @@ func TestPVPriceFromCSVStorageClass(t *testing.T) {
|
|
|
t.Errorf("Error in NodePricing: %s", err.Error())
|
|
|
} else {
|
|
|
gotPrice := resPV.Cost
|
|
|
- if gotPrice != wantPrice {
|
|
|
- t.Errorf("Wanted price '%s' got price '%s'", wantPrice, gotPrice)
|
|
|
+ wantPriceFloat, _ := strconv.ParseFloat(wantPrice, 64)
|
|
|
+ gotPriceFloat, _ := strconv.ParseFloat(gotPrice, 64)
|
|
|
+ if gotPriceFloat != wantPriceFloat {
|
|
|
+ t.Errorf("Wanted price '%f' got price '%f'", wantPriceFloat, gotPriceFloat)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -204,8 +209,10 @@ func TestNodePriceFromCSVWithGPU(t *testing.T) {
|
|
|
if gotGPU != wantGPU {
|
|
|
t.Errorf("Wanted gpu count '%s' got gpu count '%s'", wantGPU, gotGPU)
|
|
|
}
|
|
|
- if gotPrice != wantPrice {
|
|
|
- t.Errorf("Wanted price '%s' got price '%s'", wantPrice, gotPrice)
|
|
|
+ wantPriceFloat, _ := strconv.ParseFloat(wantPrice, 64)
|
|
|
+ gotPriceFloat, _ := strconv.ParseFloat(gotPrice, 64)
|
|
|
+ if gotPriceFloat != wantPriceFloat {
|
|
|
+ t.Errorf("Wanted price '%f' got price '%f'", wantPriceFloat, gotPriceFloat)
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -220,8 +227,10 @@ func TestNodePriceFromCSVWithGPU(t *testing.T) {
|
|
|
if gotGPU != wantGPU {
|
|
|
t.Errorf("Wanted gpu count '%s' got gpu count '%s'", wantGPU, gotGPU)
|
|
|
}
|
|
|
- if gotPrice != wantPrice2 {
|
|
|
- t.Errorf("Wanted price '%s' got price '%s'", wantPrice2, gotPrice)
|
|
|
+ wantPriceFloat, _ := strconv.ParseFloat(wantPrice2, 64)
|
|
|
+ gotPriceFloat, _ := strconv.ParseFloat(gotPrice, 64)
|
|
|
+ if gotPriceFloat != wantPriceFloat {
|
|
|
+ t.Errorf("Wanted price '%f' got price '%f'", wantPriceFloat, gotPriceFloat)
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -255,8 +264,10 @@ func TestNodePriceFromCSVSpecialChar(t *testing.T) {
|
|
|
t.Errorf("Error in NodePricing: %s", err.Error())
|
|
|
} else {
|
|
|
gotPrice := resN.Cost
|
|
|
- if gotPrice != wantPrice {
|
|
|
- t.Errorf("Wanted price '%s' got price '%s'", wantPrice, gotPrice)
|
|
|
+ wantPriceFloat, _ := strconv.ParseFloat(wantPrice, 64)
|
|
|
+ gotPriceFloat, _ := strconv.ParseFloat(gotPrice, 64)
|
|
|
+ if gotPriceFloat != wantPriceFloat {
|
|
|
+ t.Errorf("Wanted price '%f' got price '%f'", wantPriceFloat, gotPriceFloat)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -291,8 +302,10 @@ func TestNodePriceFromCSV(t *testing.T) {
|
|
|
t.Errorf("Error in NodePricing: %s", err.Error())
|
|
|
} else {
|
|
|
gotPrice := resN.Cost
|
|
|
- if gotPrice != wantPrice {
|
|
|
- t.Errorf("Wanted price '%s' got price '%s'", wantPrice, gotPrice)
|
|
|
+ wantPriceFloat, _ := strconv.ParseFloat(wantPrice, 64)
|
|
|
+ gotPriceFloat, _ := strconv.ParseFloat(gotPrice, 64)
|
|
|
+ if gotPriceFloat != wantPriceFloat {
|
|
|
+ t.Errorf("Wanted price '%f' got price '%f'", wantPriceFloat, gotPriceFloat)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -367,8 +380,10 @@ func TestNodePriceFromCSVWithRegion(t *testing.T) {
|
|
|
t.Errorf("Error in NodePricing: %s", err.Error())
|
|
|
} else {
|
|
|
gotPrice := resN.Cost
|
|
|
- if gotPrice != wantPrice {
|
|
|
- t.Errorf("Wanted price '%s' got price '%s'", wantPrice, gotPrice)
|
|
|
+ wantPriceFloat, _ := strconv.ParseFloat(wantPrice, 64)
|
|
|
+ gotPriceFloat, _ := strconv.ParseFloat(gotPrice, 64)
|
|
|
+ if gotPriceFloat != wantPriceFloat {
|
|
|
+ t.Errorf("Wanted price '%f' got price '%f'", wantPriceFloat, gotPriceFloat)
|
|
|
}
|
|
|
}
|
|
|
k2 := c.GetKey(n2.Labels, n2)
|
|
|
@@ -377,8 +392,10 @@ func TestNodePriceFromCSVWithRegion(t *testing.T) {
|
|
|
t.Errorf("Error in NodePricing: %s", err.Error())
|
|
|
} else {
|
|
|
gotPrice := resN2.Cost
|
|
|
- if gotPrice != wantPrice2 {
|
|
|
- t.Errorf("Wanted price '%s' got price '%s'", wantPrice2, gotPrice)
|
|
|
+ wantPriceFloat, _ := strconv.ParseFloat(wantPrice2, 64)
|
|
|
+ gotPriceFloat, _ := strconv.ParseFloat(gotPrice, 64)
|
|
|
+ if gotPriceFloat != wantPriceFloat {
|
|
|
+ t.Errorf("Wanted price '%f' got price '%f'", wantPriceFloat, gotPriceFloat)
|
|
|
}
|
|
|
}
|
|
|
k3 := c.GetKey(n3.Labels, n3)
|
|
|
@@ -387,8 +404,10 @@ func TestNodePriceFromCSVWithRegion(t *testing.T) {
|
|
|
t.Errorf("Error in NodePricing: %s", err.Error())
|
|
|
} else {
|
|
|
gotPrice := resN3.Cost
|
|
|
- if gotPrice != wantPrice3 {
|
|
|
- t.Errorf("Wanted price '%s' got price '%s'", wantPrice3, gotPrice)
|
|
|
+ wantPriceFloat, _ := strconv.ParseFloat(wantPrice3, 64)
|
|
|
+ gotPriceFloat, _ := strconv.ParseFloat(gotPrice, 64)
|
|
|
+ if gotPriceFloat != wantPriceFloat {
|
|
|
+ t.Errorf("Wanted price '%f' got price '%f'", wantPriceFloat, gotPriceFloat)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -573,8 +592,10 @@ func TestNodePriceFromCSVWithCase(t *testing.T) {
|
|
|
t.Errorf("Error in NodePricing: %s", err.Error())
|
|
|
} else {
|
|
|
gotPrice := resN.Cost
|
|
|
- if gotPrice != wantPrice {
|
|
|
- t.Errorf("Wanted price '%s' got price '%s'", wantPrice, gotPrice)
|
|
|
+ wantPriceFloat, _ := strconv.ParseFloat(wantPrice, 64)
|
|
|
+ gotPriceFloat, _ := strconv.ParseFloat(gotPrice, 64)
|
|
|
+ if gotPriceFloat != wantPriceFloat {
|
|
|
+ t.Errorf("Wanted price '%f' got price '%f'", wantPriceFloat, gotPriceFloat)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -616,8 +637,10 @@ func TestNodePriceFromCSVMixed(t *testing.T) {
|
|
|
t.Errorf("Error in NodePricing: %s", err.Error())
|
|
|
} else {
|
|
|
gotPrice := resN.Cost
|
|
|
- if gotPrice != wantPrice {
|
|
|
- t.Errorf("Wanted price '%s' got price '%s'", wantPrice, gotPrice)
|
|
|
+ wantPriceFloat, _ := strconv.ParseFloat(wantPrice, 64)
|
|
|
+ gotPriceFloat, _ := strconv.ParseFloat(gotPrice, 64)
|
|
|
+ if gotPriceFloat != wantPriceFloat {
|
|
|
+ t.Errorf("Wanted price '%f' got price '%f'", wantPriceFloat, gotPriceFloat)
|
|
|
}
|
|
|
}
|
|
|
k2 := c.GetKey(n2.Labels, n2)
|
|
|
@@ -626,8 +649,10 @@ func TestNodePriceFromCSVMixed(t *testing.T) {
|
|
|
t.Errorf("Error in NodePricing: %s", err.Error())
|
|
|
} else {
|
|
|
gotPrice := resN2.Cost
|
|
|
- if gotPrice != wantPrice2 {
|
|
|
- t.Errorf("Wanted price '%s' got price '%s'", wantPrice2, gotPrice)
|
|
|
+ wantPriceFloat, _ := strconv.ParseFloat(wantPrice2, 64)
|
|
|
+ gotPriceFloat, _ := strconv.ParseFloat(gotPrice, 64)
|
|
|
+ if gotPriceFloat != wantPriceFloat {
|
|
|
+ t.Errorf("Wanted price '%f' got price '%f'", wantPriceFloat, gotPriceFloat)
|
|
|
}
|
|
|
}
|
|
|
|