-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move tests back into handler packages
- Loading branch information
Showing
12 changed files
with
391 additions
and
172 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
42 changes: 42 additions & 0 deletions
42
pkg/handlers/aws/mutation/iaminstanceprofile/variables_test.go
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,42 @@ | ||
// Copyright 2023 D2iQ, Inc. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package iaminstanceprofile | ||
|
||
import ( | ||
"testing" | ||
|
||
"k8s.io/utils/ptr" | ||
|
||
"github.com/d2iq-labs/capi-runtime-extensions/api/v1alpha1" | ||
"github.com/d2iq-labs/capi-runtime-extensions/common/pkg/testutils/capitest" | ||
awsclusterconfig "github.com/d2iq-labs/capi-runtime-extensions/pkg/handlers/aws/clusterconfig" | ||
"github.com/d2iq-labs/capi-runtime-extensions/pkg/handlers/generic/clusterconfig" | ||
) | ||
|
||
func TestVariableValidation(t *testing.T) { | ||
capitest.ValidateDiscoverVariables( | ||
t, | ||
clusterconfig.MetaVariableName, | ||
ptr.To(v1alpha1.ClusterConfigSpec{AWS: &v1alpha1.AWSSpec{}}.VariableSchema()), | ||
true, | ||
awsclusterconfig.NewVariable, | ||
capitest.VariableTestDef{ | ||
Name: "AMI specification", | ||
Vals: v1alpha1.ClusterConfigSpec{ | ||
ControlPlane: &v1alpha1.NodeConfigSpec{ | ||
AWS: &v1alpha1.AWSNodeSpec{ | ||
AMISpec: &v1alpha1.AMISpec{ | ||
ID: "ami-1234", | ||
Lookup: &v1alpha1.AMILookup{ | ||
Format: "capa-ami-{{.BaseOS}}-?{{.K8sVersion}}-*", | ||
BaseOS: "rhel-8.4", | ||
Org: "12345678", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
) | ||
} |
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,35 @@ | ||
// Copyright 2023 D2iQ, Inc. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package instancetype | ||
|
||
import ( | ||
"testing" | ||
|
||
"k8s.io/utils/ptr" | ||
|
||
"github.com/d2iq-labs/capi-runtime-extensions/api/v1alpha1" | ||
"github.com/d2iq-labs/capi-runtime-extensions/common/pkg/testutils/capitest" | ||
awsclusterconfig "github.com/d2iq-labs/capi-runtime-extensions/pkg/handlers/aws/clusterconfig" | ||
"github.com/d2iq-labs/capi-runtime-extensions/pkg/handlers/generic/clusterconfig" | ||
) | ||
|
||
func TestVariableValidation(t *testing.T) { | ||
capitest.ValidateDiscoverVariables( | ||
t, | ||
clusterconfig.MetaVariableName, | ||
ptr.To(v1alpha1.ClusterConfigSpec{AWS: &v1alpha1.AWSSpec{}}.VariableSchema()), | ||
true, | ||
awsclusterconfig.NewVariable, | ||
capitest.VariableTestDef{ | ||
Name: "specified instance type", | ||
Vals: v1alpha1.ClusterConfigSpec{ | ||
ControlPlane: &v1alpha1.NodeConfigSpec{ | ||
AWS: &v1alpha1.AWSNodeSpec{ | ||
InstanceType: ptr.To(v1alpha1.InstanceType("m5.small")), | ||
}, | ||
}, | ||
}, | ||
}, | ||
) | ||
} |
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,33 @@ | ||
// Copyright 2023 D2iQ, Inc. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package region | ||
|
||
import ( | ||
"testing" | ||
|
||
"k8s.io/utils/ptr" | ||
|
||
"github.com/d2iq-labs/capi-runtime-extensions/api/v1alpha1" | ||
"github.com/d2iq-labs/capi-runtime-extensions/common/pkg/testutils/capitest" | ||
awsclusterconfig "github.com/d2iq-labs/capi-runtime-extensions/pkg/handlers/aws/clusterconfig" | ||
"github.com/d2iq-labs/capi-runtime-extensions/pkg/handlers/generic/clusterconfig" | ||
) | ||
|
||
func TestVariableValidation(t *testing.T) { | ||
capitest.ValidateDiscoverVariables( | ||
t, | ||
clusterconfig.MetaVariableName, | ||
ptr.To(v1alpha1.ClusterConfigSpec{AWS: &v1alpha1.AWSSpec{}}.VariableSchema()), | ||
true, | ||
awsclusterconfig.NewVariable, | ||
capitest.VariableTestDef{ | ||
Name: "specified region", | ||
Vals: v1alpha1.ClusterConfigSpec{ | ||
AWS: &v1alpha1.AWSSpec{ | ||
Region: ptr.To(v1alpha1.Region("a-specified-region")), | ||
}, | ||
}, | ||
}, | ||
) | ||
} |
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,45 @@ | ||
// Copyright 2023 D2iQ, Inc. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package cni | ||
|
||
import ( | ||
"testing" | ||
|
||
"k8s.io/utils/ptr" | ||
|
||
"github.com/d2iq-labs/capi-runtime-extensions/api/v1alpha1" | ||
"github.com/d2iq-labs/capi-runtime-extensions/common/pkg/testutils/capitest" | ||
"github.com/d2iq-labs/capi-runtime-extensions/pkg/handlers/generic/clusterconfig" | ||
) | ||
|
||
func TestVariableValidation(t *testing.T) { | ||
capitest.ValidateDiscoverVariables( | ||
t, | ||
clusterconfig.MetaVariableName, | ||
ptr.To(v1alpha1.GenericClusterConfig{}.VariableSchema()), | ||
false, | ||
clusterconfig.NewVariable, | ||
capitest.VariableTestDef{ | ||
Name: "set with valid provider", | ||
Vals: v1alpha1.GenericClusterConfig{ | ||
Addons: &v1alpha1.Addons{ | ||
CNI: &v1alpha1.CNI{ | ||
Provider: v1alpha1.CNIProviderCalico, | ||
}, | ||
}, | ||
}, | ||
}, | ||
capitest.VariableTestDef{ | ||
Name: "set with invalid provider", | ||
Vals: v1alpha1.GenericClusterConfig{ | ||
Addons: &v1alpha1.Addons{ | ||
CNI: &v1alpha1.CNI{ | ||
Provider: "invalid-provider", | ||
}, | ||
}, | ||
}, | ||
ExpectError: true, | ||
}, | ||
) | ||
} |
Oops, something went wrong.