public void ParseKubeConfigValidConfigFile() { string dirInfo = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); KubeConfig kubeConfig = KubeConfigUtils.ParseKubeConfig( Path.Combine(Path.Combine(dirInfo, KubeConfigParsingTests.TEST_RESOURCES_DIR), KubeConfigParsingTests.TEST_KUBE_CONFIG)); // Validate Assert.IsNotNull(kubeConfig); CollectionAssert.IsNotEmpty(kubeConfig.Clusters); CollectionAssert.IsNotEmpty(kubeConfig.Contexts); CollectionAssert.IsNotEmpty(kubeConfig.Users); Assert.AreEqual("v1", kubeConfig.ApiVersion); Assert.AreEqual("Config", kubeConfig.Kind); Assert.AreEqual(KubeConfigParsingTests.TEST_CURRENT_CONTEXT, kubeConfig.CurrentContext); Assert.AreEqual(KubeConfigParsingTests.TEST_CONFIG_SERVER_ENDPOINT, kubeConfig.Clusters.FirstOrDefault().ClusterData.Server); Assert.AreEqual(KubeConfigParsingTests.TEST_CONFIG_USER, kubeConfig.Users.FirstOrDefault().Name); }
public void ParseKubeConfigInvalidPath() { Assert.Throws <Exception>(() => KubeConfigUtils.ParseKubeConfig("invalid\\path")); }