This commit is contained in:
asteam
2025-07-15 17:39:18 +03:00
parent 1f8637400f
commit 7dacf35cd6
163 changed files with 4322 additions and 504 deletions

View File

@@ -20,7 +20,10 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/sep"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/stack"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/tasks"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/trunk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/zone"
account_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/account"
audit_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/audit"
bservice_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/bservice"
@@ -39,7 +42,9 @@ import (
sep_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/sep"
stack_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/stack"
tasks_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/tasks"
trunk_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/trunk"
vins_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/vins"
zone_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/zone"
)
// TestGetListCloudAPI tests platforms responses vs. json tags of golang structures in cloudapi get/list methods
@@ -316,6 +321,26 @@ func TestGetListCloudAPI(t *testing.T) {
t.Errorf("Can not test Tasks get because Tasks list is empty")
}
// Trunk
// List
bytes, err = client.CloudAPI().Trunk().ListRaw(context.Background(), trunk.ListRequest{})
if err != nil {
t.Error(err)
}
getResult("Trunk list", bytes, tasks.ListTasks{}, t)
// Get
listTrunk, _ := client.CloudAPI().Trunk().List(context.Background(), trunk.ListRequest{})
if len(listTrunk.Data) > 0 {
id := listTrunk.Data[0].ID
bytes, err = client.CloudAPI().Trunk().GetRaw(context.Background(), trunk.GetRequest{TrunkID: id})
if err != nil {
t.Error(err)
}
getResult("Trunk get", bytes, trunk.ItemTrunk{}, t)
} else {
t.Errorf("Can not test Trunk get because Trunk list is empty")
}
// VINS
// List
bytes, err = client.CloudAPI().VINS().ListRaw(context.Background(), vins.ListRequest{})
@@ -336,6 +361,25 @@ func TestGetListCloudAPI(t *testing.T) {
t.Errorf("Can not test VINS get because VINS list is empty")
}
// Zone
// List
bytes, err = client.CloudAPI().Zone().ListRaw(context.Background(), zone.ListRequest{})
if err != nil {
t.Error(err)
}
getResult("Zone list", bytes, vins.ListVINS{}, t)
// Get
ListZones, _ := client.CloudAPI().Zone().List(context.Background(), zone.ListRequest{})
if len(ListZones.Data) > 0 {
id := ListZones.Data[0].ID
bytes, err = client.CloudAPI().Zone().GetRaw(context.Background(), zone.GetRequest{ID: id})
if err != nil {
t.Error(err)
}
getResult("Zone get", bytes, zone.RecordZone{}, t)
} else {
t.Errorf("Can not test Zone get because Zones list is empty")
}
}
// WARNING: not working correctly due to inclusions of tagless structures in cloudbroker
@@ -348,6 +392,7 @@ func TestGetListCloudbroker(t *testing.T) {
t.Fatalf("Cannot get client: %v", err)
}
const logFileName = "test_get_list_cloudbroker.log"
// Account
// List
bytes, err = client.CloudBroker().Account().ListRaw(context.Background(), account_cb.ListRequest{})
@@ -690,6 +735,26 @@ func TestGetListCloudbroker(t *testing.T) {
}
getResult("Tasks list", bytes, tasks_cb.ListTasks{}, t)
// Trunk
// List
bytes, err = client.CloudBroker().Trunk().ListRaw(context.Background(), trunk_cb.ListRequest{})
if err != nil {
t.Error(err)
}
getResult("Trunk list", bytes, trunk_cb.ListTrunks{}, t)
// Get
listTrunks, _ := client.CloudBroker().Trunk().List(context.Background(), trunk_cb.ListRequest{})
if len(listTrunks.Data) > 0 {
id := listTrunks.Data[0].ID
bytes, err = client.CloudBroker().Trunk().GetRaw(context.Background(), trunk_cb.GetRequest{TrunkID: id})
if err != nil {
t.Error(err)
}
getResult("Trunk get", bytes, trunk_cb.ItemTrunk{}, t)
} else {
t.Errorf("Can not test Trunk get because Trunk list is empty")
}
// VINS
// List
bytes, err = client.CloudBroker().VINS().ListRaw(context.Background(), vins_cb.ListRequest{})
@@ -709,6 +774,26 @@ func TestGetListCloudbroker(t *testing.T) {
} else {
t.Errorf("Can not test VINS get because VINS list is empty")
}
// Zone
// List
bytes, err = client.CloudBroker().Zone().ListRaw(context.Background(), zone_cb.ListRequest{})
if err != nil {
t.Error(err)
}
getResult("Zone list", bytes, zone.ListZones{}, t)
// Get
ListZones, _ := client.CloudBroker().Zone().List(context.Background(), zone_cb.ListRequest{})
if len(ListZones.Data) > 0 {
id := ListZones.Data[0].ID
bytes, err = client.CloudBroker().Zone().GetRaw(context.Background(), zone_cb.GetRequest{ID: id})
if err != nil {
t.Error(err)
}
getResult("Zone get", bytes, zone_cb.RecordZone{}, t)
} else {
t.Errorf("Can not test Zone get because Zones list is empty")
}
}
// TestRequestsCloudAPI tests platform requests vs. golang request structures in sdk for cloudapi requests