-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors_test.go
35 lines (26 loc) · 1.02 KB
/
errors_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright 2022 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package environs_test
import (
"fmt"
"github.com/juju/errors"
jc "github.com/juju/testing/checkers"
. "gopkg.in/check.v1"
"github.com/juju/juju/environs"
)
type errorsSuite struct {
}
func (*errorsSuite) TestZoneIndependentErrorConforms(c *C) {
err := fmt.Errorf("fly screens on a submarine: %w", environs.ErrAvailabilityZoneIndependent)
c.Assert(errors.Is(err, environs.ErrAvailabilityZoneIndependent), jc.IsTrue)
err = fmt.Errorf("replace with solid doors: %w", err)
err = environs.ZoneIndependentError(err)
c.Assert(errors.Is(err, environs.ErrAvailabilityZoneIndependent), jc.IsTrue)
err = fmt.Errorf("or stay on dry land: %w", err)
c.Assert(errors.Is(err, environs.ErrAvailabilityZoneIndependent), jc.IsTrue)
}
func (*errorsSuite) TestZoneIndependentErrorIsLocationer(c *C) {
err := environs.ZoneIndependentError(errors.New("lets not talk about submarine's any more"))
_, ok := err.(errors.Locationer)
c.Assert(ok, jc.IsTrue)
}