github.com/Finschia/finschia-sdk@v0.48.1/x/authz/authorization_grant_test.go (about) 1 package authz 2 3 import ( 4 "testing" 5 "time" 6 7 // banktypes "github.com/Finschia/finschia-sdk/x/bank/types" 8 "github.com/stretchr/testify/require" 9 ) 10 11 func expecError(r *require.Assertions, expected string, received error) { 12 if expected == "" { 13 r.NoError(received) 14 } else { 15 r.Error(received) 16 r.Contains(received.Error(), expected) 17 } 18 } 19 20 func TestNewGrant(t *testing.T) { 21 // ba := banktypes.NewSendAuthorization(sdk.NewCoins(sdk.NewInt64Coin("foo", 123))) 22 a := NewGenericAuthorization("some-type") 23 tcs := []struct { 24 title string 25 a Authorization 26 blockTime time.Time 27 expire time.Time 28 err string 29 }{ 30 {"wrong expire time (1)", a, time.Unix(10, 0), time.Unix(8, 0), "expiration must be after"}, 31 {"wrong expire time (2)", a, time.Unix(10, 0), time.Unix(10, 0), "expiration must be after"}, 32 {"good expire time (1)", a, time.Unix(10, 0), time.Unix(10, 1), ""}, 33 {"good expire time (2)", a, time.Unix(10, 0), time.Unix(11, 0), ""}, 34 } 35 36 for _, tc := range tcs { 37 t.Run(tc.title, func(t *testing.T) { 38 // _, err := NewGrant(tc.blockTime, tc.a, tc.expire) 39 _, err := NewGrant(tc.blockTime, tc.a, tc.expire) 40 expecError(require.New(t), tc.err, err) 41 }) 42 } 43 }