| // Copyright 2015 The Vanadium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| func TestMaybeWrapError(t *testing.T) { |
| ctx, _ := context.RootContext() |
| {errors.New("wrap this error"), true}, |
| {verror.NewErrUnknown(ctx), false}, |
| {flow.NewErrAuth(ctx, nil), false}, |
| for _, test := range tests { |
| werr := MaybeWrapError(flow.ErrAuth, ctx, test.err) |
| // If the returned error is not equal to the original error it was wrapped. |
| if wasWrapped := werr.Error() != msg; wasWrapped != test.wrap { |
| t.Errorf("wanted %v to be wrapped", test.err) |
| t.Errorf("did not want %v to be wrapped", test.err) |