github.com/hairyhenderson/templater@v3.5.0+incompatible/funcs/aws_test.go (about) 1 package funcs 2 3 import ( 4 "testing" 5 6 "github.com/hairyhenderson/gomplate/aws" 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func TestNSIsIdempotent(t *testing.T) { 11 left := AWSNS() 12 right := AWSNS() 13 assert.True(t, left == right) 14 } 15 16 func TestAWSFuncs(t *testing.T) { 17 m := aws.NewDummyEc2Meta() 18 i := aws.NewDummyEc2Info(m) 19 af := &Funcs{meta: m, info: i} 20 assert.Equal(t, "unknown", must(af.EC2Region())) 21 assert.Equal(t, "", must(af.EC2Meta("foo"))) 22 assert.Equal(t, "", must(af.EC2Tag("foo"))) 23 assert.Equal(t, "unknown", must(af.EC2Region())) 24 } 25 26 func must(r interface{}, err error) interface{} { 27 if err != nil { 28 panic(err) 29 } 30 return r 31 }