github.com/angdraug/packer@v1.3.2/template/interpolate/i_test.go (about)

     1  package interpolate
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestIRender(t *testing.T) {
     8  	cases := map[string]struct {
     9  		Ctx    *Context
    10  		Value  string
    11  		Result string
    12  	}{
    13  		"basic": {
    14  			nil,
    15  			"foo",
    16  			"foo",
    17  		},
    18  	}
    19  
    20  	for k, tc := range cases {
    21  		i := &I{Value: tc.Value}
    22  		result, err := i.Render(tc.Ctx)
    23  		if err != nil {
    24  			t.Fatalf("%s\n\ninput: %s\n\nerr: %s", k, tc.Value, err)
    25  		}
    26  		if result != tc.Result {
    27  			t.Fatalf(
    28  				"%s\n\ninput: %s\n\nexpected: %s\n\ngot: %s",
    29  				k, tc.Value, tc.Result, result)
    30  		}
    31  	}
    32  }