-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added new unit tests (#501) Co-authored-by: ”Srinivas <“[email protected]”> * new unit testcases (#502) * added new unit tests * added new unit test cases --------- Co-authored-by: ”Srinivas <“[email protected]”> * PLT-1314: Completed Mock Api Initial implementation (#506) * initial commit * draft * draft 2 * completed project unitest with mock * refreshed so mod * mockserver fix * Fixed mack api server * completed unitest for data source appliance * PLT-1362: Revamped Unit test and achieved 55% of code coverage (#509) * adding unit case's for filter * completed 4 data source unit test * complete unit test for dt packs * kubevirt common unit test completion * fixed data source cluster profile * unit test completed for data source app profiles * Unitest coverage complete with 50% * Completed to 53 percent * macros mock unit test (#508) * macros mock unit test * removed unwanted go dependencies --------- Co-authored-by: ”Srinivas <“[email protected]”> Co-authored-by: Sivaanand Murugesan <[email protected]> * Completed unit test coverage to 55 percent --------- Co-authored-by: Srinivas DM <[email protected]> Co-authored-by: ”Srinivas <“[email protected]”> * test unit test in git action * fix git action * try1 * fix kube_config test * unit test fix * fixed minor issue * cleaned up all commented test --------- Co-authored-by: Srinivas DM <[email protected]> Co-authored-by: ”Srinivas <“[email protected]”>
- Loading branch information
1 parent
245f720
commit 1ae5a9f
Showing
102 changed files
with
10,852 additions
and
1,499 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
package spectrocloud | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestToAppDeploymentClusterGroupEntity(t *testing.T) { | ||
d := schema.TestResourceDataRaw(t, appDeploymentSchema(), map[string]interface{}{ | ||
"name": "test-cluster-group", | ||
"config": []interface{}{ | ||
map[string]interface{}{ | ||
"cluster_group_uid": "cg-uid", | ||
"cluster_name": "cluster-name", | ||
"limits": []interface{}{ | ||
map[string]interface{}{ | ||
"cpu": 4, | ||
"memory": 2048, | ||
"storage": 100, | ||
}, | ||
}, | ||
}, | ||
}, | ||
"application_profile_uid": "app-profile-uid", | ||
"labels": map[string]interface{}{ | ||
"env": "test", | ||
}, | ||
}) | ||
|
||
entity := toAppDeploymentClusterGroupEntity(d) | ||
|
||
assert.NotNil(t, entity) | ||
assert.Equal(t, "test-cluster-group", entity.Metadata.Name) | ||
assert.Equal(t, "cg-uid", *entity.Spec.Config.TargetSpec.ClusterGroupUID) | ||
assert.Equal(t, int32(4), entity.Spec.Config.TargetSpec.ClusterLimits.CPU) | ||
assert.Equal(t, int32(2048), entity.Spec.Config.TargetSpec.ClusterLimits.MemoryMiB) | ||
assert.Equal(t, int32(100), entity.Spec.Config.TargetSpec.ClusterLimits.StorageGiB) | ||
assert.Equal(t, "cluster-name", *entity.Spec.Config.TargetSpec.ClusterName) | ||
assert.Equal(t, "app-profile-uid", *entity.Spec.Profile.AppProfileUID) | ||
} | ||
|
||
func TestToAppDeploymentVirtualClusterEntity(t *testing.T) { | ||
d := schema.TestResourceDataRaw(t, appDeploymentSchema(), map[string]interface{}{ | ||
"name": "test-virtual-cluster", | ||
"config": []interface{}{ | ||
map[string]interface{}{ | ||
"cluster_uid": "vc-uid", | ||
}, | ||
}, | ||
"application_profile_uid": "app-profile-uid", | ||
"labels": map[string]interface{}{ | ||
"env": "prod", | ||
}, | ||
}) | ||
|
||
entity := toAppDeploymentVirtualClusterEntity(d) | ||
|
||
assert.NotNil(t, entity) | ||
assert.Equal(t, "test-virtual-cluster", entity.Metadata.Name) | ||
assert.Equal(t, "vc-uid", *entity.Spec.Config.TargetSpec.ClusterUID) | ||
assert.Equal(t, "app-profile-uid", *entity.Spec.Profile.AppProfileUID) | ||
} | ||
|
||
// Helper function to return a schema.ResourceData schema for testing | ||
func appDeploymentSchema() map[string]*schema.Schema { | ||
return map[string]*schema.Schema{ | ||
"name": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
"config": { | ||
Type: schema.TypeList, | ||
Required: true, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"cluster_group_uid": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
}, | ||
"cluster_name": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
}, | ||
"cluster_uid": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
}, | ||
"limits": { | ||
Type: schema.TypeList, | ||
Optional: true, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"cpu": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
}, | ||
"memory": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
}, | ||
"storage": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
"application_profile_uid": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
"labels": { | ||
Type: schema.TypeMap, | ||
Optional: true, | ||
Elem: &schema.Schema{ | ||
Type: schema.TypeString, | ||
}, | ||
}, | ||
} | ||
} |
Oops, something went wrong.