2014-04-06 13:21:22 -04:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
2019-06-14 04:55:10 -04:00
|
|
|
|
2020-12-17 16:29:25 -05:00
|
|
|
"github.com/hashicorp/packer-plugin-sdk/template/interpolate"
|
2014-04-06 13:21:22 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestPrlctlConfigPrepare_Prlctl(t *testing.T) {
|
|
|
|
// Test with empty
|
|
|
|
c := new(PrlctlConfig)
|
2019-06-14 04:55:10 -04:00
|
|
|
errs := c.Prepare(interpolate.NewContext())
|
2014-04-06 13:21:22 -04:00
|
|
|
if len(errs) > 0 {
|
|
|
|
t.Fatalf("err: %#v", errs)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(c.Prlctl, [][]string{}) {
|
|
|
|
t.Fatalf("bad: %#v", c.Prlctl)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test with a good one
|
|
|
|
c = new(PrlctlConfig)
|
|
|
|
c.Prlctl = [][]string{
|
|
|
|
{"foo", "bar", "baz"},
|
|
|
|
}
|
2019-06-14 04:55:10 -04:00
|
|
|
errs = c.Prepare(interpolate.NewContext())
|
2014-04-06 13:21:22 -04:00
|
|
|
if len(errs) > 0 {
|
|
|
|
t.Fatalf("err: %#v", errs)
|
|
|
|
}
|
|
|
|
|
|
|
|
expected := [][]string{
|
2016-11-01 17:08:04 -04:00
|
|
|
{"foo", "bar", "baz"},
|
2014-04-06 13:21:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(c.Prlctl, expected) {
|
|
|
|
t.Fatalf("bad: %#v", c.Prlctl)
|
|
|
|
}
|
|
|
|
}
|