Check for empty deployment targets and matchers

Fixes #9220
This commit is contained in:
Joe Mooring 2021-11-30 13:39:47 -08:00 committed by Bjørn Erik Pedersen
parent 08a863e1e8
commit f122771fb1
2 changed files with 39 additions and 1 deletions

View file

@ -11,6 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !nodeploy
// +build !nodeploy
package deploy
@ -21,7 +22,6 @@ import (
qt "github.com/frankban/quicktest"
"github.com/gohugoio/hugo/config"
)
func TestDecodeConfigFromTOML(t *testing.T) {
@ -169,3 +169,33 @@ func TestDecodeConfigDefault(t *testing.T) {
c.Assert(len(dcfg.Targets), qt.Equals, 0)
c.Assert(len(dcfg.Matchers), qt.Equals, 0)
}
func TestEmptyTarget(t *testing.T) {
c := qt.New(t)
tomlConfig := `
[deployment]
[[deployment.targets]]
`
cfg, err := config.FromConfigString(tomlConfig, "toml")
c.Assert(err, qt.IsNil)
_, err = decodeConfig(cfg)
c.Assert(err, qt.Not(qt.IsNil))
}
func TestEmptyMatcher(t *testing.T) {
c := qt.New(t)
tomlConfig := `
[deployment]
[[deployment.matchers]]
`
cfg, err := config.FromConfigString(tomlConfig, "toml")
c.Assert(err, qt.IsNil)
_, err = decodeConfig(cfg)
c.Assert(err, qt.Not(qt.IsNil))
fmt.Printf("JMM-1: %s", err)
}