Test yaml validity without a new dependency [#15]
It turns out testify already depends on yaml, so we aren't adding anything new by using it here.
This commit is contained in:
@@ -2,6 +2,7 @@ package run
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
@@ -92,6 +93,10 @@ func (suite *InitKubeTestSuite) TestExecuteGeneratesConfig() {
|
||||
suite.Contains(string(contents), expected)
|
||||
}
|
||||
|
||||
// the generated config should be valid yaml, with no repeated keys
|
||||
conf := map[string]interface{}{}
|
||||
suite.NoError(yaml.UnmarshalStrict(contents, &conf))
|
||||
|
||||
// test the other branch of the certificate/SkipTLSVerify conditional
|
||||
init.SkipTLSVerify = true
|
||||
init.Certificate = ""
|
||||
@@ -101,6 +106,9 @@ func (suite *InitKubeTestSuite) TestExecuteGeneratesConfig() {
|
||||
contents, err = ioutil.ReadFile(configFile.Name())
|
||||
suite.Require().NoError(err)
|
||||
suite.Contains(string(contents), "insecure-skip-tls-verify: true")
|
||||
|
||||
conf = map[string]interface{}{}
|
||||
suite.NoError(yaml.UnmarshalStrict(contents, &conf))
|
||||
}
|
||||
|
||||
func (suite *InitKubeTestSuite) TestPrepareParseError() {
|
||||
|
||||
Reference in New Issue
Block a user