Skip to content

Commit

Permalink
Use MatchYAML in kubeconfig tests
Browse files Browse the repository at this point in the history
  • Loading branch information
errordeveloper committed Feb 13, 2019
1 parent 1412fd1 commit e3b8b1a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pkg/utils/kubeconfig/kubeconfig_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package kubeconfig_test

import (
"bytes"
"io/ioutil"
"os"

Expand Down Expand Up @@ -241,7 +240,7 @@ var _ = Describe("Kubeconfig", func() {

configFileAsBytes, err := ioutil.ReadFile(configFile.Name())
Expect(err).To(BeNil())
Expect(bytes.Equal(configFileAsBytes, emptyClusterAsBytes)).To(BeTrue(), "Failed to delete cluster from config")
Expect(configFileAsBytes).To(MatchYAML(emptyClusterAsBytes), "Failed to delete cluster from config")
})

It("removes current cluster from the kubeconfig if the kubeconfig file includes the cluster", func() {
Expand All @@ -250,7 +249,7 @@ var _ = Describe("Kubeconfig", func() {

configFileAsBytes, err := ioutil.ReadFile(configFile.Name())
Expect(err).To(BeNil())
Expect(bytes.Equal(configFileAsBytes, oneClusterWithoutContextAsBytes)).To(BeTrue(), "Failed to delete cluster from config")
Expect(configFileAsBytes).To(MatchYAML(oneClusterWithoutContextAsBytes), "Failed to delete cluster from config")
})

It("removes a secondary cluster from the kubeconfig if the kubeconfig file includes the cluster", func() {
Expand All @@ -259,7 +258,7 @@ var _ = Describe("Kubeconfig", func() {

configFileAsBytes, err := ioutil.ReadFile(configFile.Name())
Expect(err).To(BeNil())
Expect(bytes.Equal(configFileAsBytes, oneClusterAsBytes)).To(BeTrue(), "Failed to delete cluster from config")
Expect(configFileAsBytes).To(MatchYAML(oneClusterAsBytes), "Failed to delete cluster from config")
})

It("not change the kubeconfig if the kubeconfig does not include the cluster", func() {
Expand All @@ -268,7 +267,7 @@ var _ = Describe("Kubeconfig", func() {

configFileAsBytes, err := ioutil.ReadFile(configFile.Name())
Expect(err).To(BeNil())
Expect(bytes.Equal(configFileAsBytes, twoClustersAsBytes)).To(BeTrue(), "Should not change")
Expect(configFileAsBytes).To(MatchYAML(twoClustersAsBytes), "Should not change")
})
})
})

0 comments on commit e3b8b1a

Please sign in to comment.