Skip to content

Commit 995e905

Browse files
authored
Validation test for issue #86 (#106)
1 parent 47ddb4b commit 995e905

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

kubernetes/resource_kubectl_manifest_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,3 +822,39 @@ func TestGenerateSelfLink(t *testing.T) {
822822
link = generateSelfLink("apps/v1", "ns", "Deployment", "name")
823823
assert.Equal(t, link, "/apis/apps/v1/namespaces/ns/deployments/name")
824824
}
825+
826+
func TestAccKubectlServerSideValidationFailure(t *testing.T) {
827+
828+
config := `
829+
resource "kubectl_manifest" "test" {
830+
yaml_body = <<YAML
831+
apiVersion: networking.k8s.io/v1
832+
kind: Ingress
833+
metadata:
834+
name: ingress
835+
spec:
836+
rules:
837+
- host: "test-a.proxypile.tk"
838+
http:
839+
paths:
840+
- path: /
841+
pathType: Prefix
842+
backend:
843+
service:
844+
name: nginx.test-a.svc.cluster.local
845+
port:
846+
number: 8080
847+
YAML
848+
}
849+
`
850+
expectedError, _ := regexp.Compile(".*Invalid value: \"nginx.test-a.svc.cluster.local\": a DNS-1035 label must consist of lower case alphanumeric characters.*")
851+
resource.Test(t, resource.TestCase{
852+
Providers: testAccProviders,
853+
Steps: []resource.TestStep{
854+
{
855+
ExpectError: expectedError,
856+
Config: config,
857+
},
858+
},
859+
})
860+
}

0 commit comments

Comments
 (0)