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:
parent
1422ec77a4
commit
3b85c38714
1
go.mod
1
go.mod
|
@ -8,4 +8,5 @@ require (
|
||||||
github.com/stretchr/testify v1.4.0
|
github.com/stretchr/testify v1.4.0
|
||||||
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect
|
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect
|
||||||
golang.org/x/tools v0.0.0-20191209225234-22774f7dae43 // indirect
|
golang.org/x/tools v0.0.0-20191209225234-22774f7dae43 // indirect
|
||||||
|
gopkg.in/yaml.v2 v2.2.2
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,6 +2,7 @@ package run
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
yaml "gopkg.in/yaml.v2"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -92,6 +93,10 @@ func (suite *InitKubeTestSuite) TestExecuteGeneratesConfig() {
|
||||||
suite.Contains(string(contents), expected)
|
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
|
// test the other branch of the certificate/SkipTLSVerify conditional
|
||||||
init.SkipTLSVerify = true
|
init.SkipTLSVerify = true
|
||||||
init.Certificate = ""
|
init.Certificate = ""
|
||||||
|
@ -101,6 +106,9 @@ func (suite *InitKubeTestSuite) TestExecuteGeneratesConfig() {
|
||||||
contents, err = ioutil.ReadFile(configFile.Name())
|
contents, err = ioutil.ReadFile(configFile.Name())
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
suite.Contains(string(contents), "insecure-skip-tls-verify: true")
|
suite.Contains(string(contents), "insecure-skip-tls-verify: true")
|
||||||
|
|
||||||
|
conf = map[string]interface{}{}
|
||||||
|
suite.NoError(yaml.UnmarshalStrict(contents, &conf))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *InitKubeTestSuite) TestPrepareParseError() {
|
func (suite *InitKubeTestSuite) TestPrepareParseError() {
|
||||||
|
|
Loading…
Reference in a new issue