update go.mod and imports
This commit is contained in:
62
pkg/cloudapi/sizes/filter_test.go
Normal file
62
pkg/cloudapi/sizes/filter_test.go
Normal file
@@ -0,0 +1,62 @@
|
||||
package sizes
|
||||
|
||||
import "testing"
|
||||
|
||||
var sizeItems = ListSizes{
|
||||
{
|
||||
Description: "",
|
||||
Disks: []uint64{},
|
||||
ID: 1,
|
||||
Memory: 512,
|
||||
Name: "size_1",
|
||||
VCPUs: 2,
|
||||
},
|
||||
{
|
||||
Description: "",
|
||||
Disks: []uint64{},
|
||||
ID: 2,
|
||||
Memory: 1024,
|
||||
Name: "size_2",
|
||||
VCPUs: 4,
|
||||
},
|
||||
{
|
||||
Description: "",
|
||||
Disks: []uint64{},
|
||||
ID: 2,
|
||||
Memory: 2048,
|
||||
Name: "size_3",
|
||||
VCPUs: 6,
|
||||
},
|
||||
}
|
||||
|
||||
func TestFilterByID(t *testing.T) {
|
||||
actual := sizeItems.FilterByID(1).FindOne()
|
||||
|
||||
if actual.ID != 1 {
|
||||
t.Fatal("expected ID 1, found: ", actual.ID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByName(t *testing.T) {
|
||||
actual := sizeItems.FilterByName("size_2").FindOne()
|
||||
|
||||
if actual.Name != "size_2" {
|
||||
t.Fatal("expected Name 'size_2', found: ", actual.Name)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterFunc(t *testing.T) {
|
||||
actual := sizeItems.FilterFunc(func(is ItemSize) bool {
|
||||
return is.Memory > 512
|
||||
})
|
||||
|
||||
if len(actual) != 2 {
|
||||
t.Fatal("expected 2 found, actual: ", len(actual))
|
||||
}
|
||||
|
||||
for _, item := range actual {
|
||||
if item.Memory <= 512 {
|
||||
t.Fatal("expected Memory greater than 512, found: ", item.Memory)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package sizes
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"repos.digitalenergy.online/BASIS/decort-golang-sdk/internal/serialization"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/serialization"
|
||||
)
|
||||
|
||||
// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
package sizes
|
||||
|
||||
import (
|
||||
"repos.digitalenergy.online/BASIS/decort-golang-sdk/interfaces"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||
)
|
||||
|
||||
// Structure for creatig request to sizes
|
||||
|
||||
Reference in New Issue
Block a user