You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
662 B
Go

package operation_test
import (
"testing"
"github.com/aziis98/cabret/operation"
"github.com/aziis98/cabret/util"
"gotest.tools/assert"
)
func TestTargetShortForm(t *testing.T) {
t.Run("correct usage", func(t *testing.T) {
op := &operation.Target{}
err := op.Configure(util.ParseYAML(`
target: foo/bar/baz.txt
`))
assert.NilError(t, err)
assert.DeepEqual(t, op, &operation.Target{
PathTemplate: "foo/bar/baz.txt",
})
})
t.Run("wrong usage", func(t *testing.T) {
op := &operation.Target{}
err := op.Configure(util.ParseYAML(`
target: 123
`))
assert.Error(t, err, `expected a path template but got "123" of type int`)
})
}