예제 #1
0
        public void CreateKubernetesObject_NoConsts()
        {
            // Verify that [NotSupportedException] is thrown when the required constants
            // are not defined by the Kubernetes object type.

            Assert.Throws <NotSupportedException>(() => KubeHelper.CreateKubeObject <V1TestWithoutGroup>("test"));
            Assert.Throws <NotSupportedException>(() => KubeHelper.CreateKubeObject <V1TestWithoutApiVersion>("test"));
            Assert.Throws <NotSupportedException>(() => KubeHelper.CreateKubeObject <V1TestWithoutKind>("test"));
        }
예제 #2
0
        public void CreateKubernetesObject()
        {
            // Create a few global Kubernetes objects and verify that their ApiVersion
            // and Kind properties are initialized properly.

            var configmap = KubeHelper.CreateKubeObject <V1ConfigMap>("test");

            Assert.Equal(V1ConfigMap.KubeApiVersion, configmap.ApiVersion);
            Assert.Equal(V1ConfigMap.KubeKind, configmap.Kind);

            var deployment = KubeHelper.CreateKubeObject <V1Deployment>("test");

            Assert.Equal($"{V1Deployment.KubeGroup}/{V1Deployment.KubeApiVersion}", deployment.ApiVersion);
            Assert.Equal(V1Deployment.KubeKind, deployment.Kind);

            // Verify that a custom object can be created.

            var test = KubeHelper.CreateKubeObject <V1Test>("test");

            Assert.Equal($"{V1Test.KubeGroup}/{V1Test.KubeApiVersion}", test.ApiVersion);
            Assert.Equal(V1Test.KubeKind, test.Kind);
        }