Skip to content

Commit

Permalink
Release 4.4.c (#510)
Browse files Browse the repository at this point in the history
* 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
3 people authored Sep 3, 2024
1 parent 245f720 commit 1ae5a9f
Show file tree
Hide file tree
Showing 102 changed files with 10,852 additions and 1,499 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@ kubeconfig_*
.local
dist
providers

# ignore for mock api server
mock_server.crt
mock_server.key
MockBuild
mock_api_server.log
3 changes: 1 addition & 2 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ generate:
##@ Test Targets
.PHONY: testacc
testacc: ## Run acceptance tests
TF_ACC=1 go test -v $(TESTARGS) -covermode=atomic -coverpkg=./... -coverprofile=profile.cov ./... -timeout 120m
TF_ACC=1 go test -v $(TESTARGS) -covermode=atomic -coverpkg=./... -coverprofile=profile.cov ./spectrocloud/... -timeout 120m

##@ Development Targets

DEV_PROVIDER_VERSION=100.100.100
dev-provider: ## Generate dev provider
bash generate_dev_provider.sh $(DEV_PROVIDER_VERSION)
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.22.5
require (
github.com/go-openapi/strfmt v0.23.0
github.com/google/go-cmp v0.6.0
github.com/gorilla/mux v1.8.0
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-docs v0.16.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5m
github.com/googleapis/gnostic v0.5.1/go.mod h1:6U4PtQXGIEt/Z3h5MAT7FNofLnw9vXk2cUuW7uA/OeU=
github.com/googleapis/gnostic v0.5.5/go.mod h1:7+EbHbldMins07ALC74bsA81Ovc97DwqyJO1AENw9kA=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
Expand Down
124 changes: 124 additions & 0 deletions spectrocloud/application_create_common_test.go
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,
},
},
}
}
Loading

0 comments on commit 1ae5a9f

Please sign in to comment.