Skip to content

Commit

Permalink
Add test case for internal/errors/grpc.go (#903)
Browse files Browse the repository at this point in the history
* fix: test case name for grpc error

Signed-off-by: hlts2 <[email protected]>

* fix: add comment & test case name more clearly

Signed-off-by: hlts2 <[email protected]>

* fix: add comment & test case for ErrInvalidGRPCPort method

Signed-off-by: hlts2 <[email protected]>

* fix: apply suggestion

Signed-off-by: hlts2 <[email protected]>

* Update internal/errors/grpc.go

* Update internal/errors/grpc.go

* Apply suggestions from code review

Co-authored-by: Kiichiro YUKAWA <[email protected]>

* fix: apply suggestion about boundary value

Signed-off-by: hlts2 <[email protected]>

* 🤖 Update license headers / Format go codes and yaml files

Signed-off-by: vdaas-ci <[email protected]>

Co-authored-by: Kiichiro YUKAWA <[email protected]>
Co-authored-by: vdaas-ci <[email protected]>
  • Loading branch information
3 people authored Jan 8, 2021
1 parent fd20606 commit 0e93f6b
Show file tree
Hide file tree
Showing 3 changed files with 608 additions and 9 deletions.
13 changes: 7 additions & 6 deletions hack/license/gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,16 @@ var (
)

type Data struct {
Escape string
Escape string
Maintainer string
Year int
Year int
}

const (
defaultMaintainer = "vdaas.org vald team <[email protected]>"
maintainerKey = "MAINTAINER"
defaultMaintainer = "vdaas.org vald team <[email protected]>"
maintainerKey = "MAINTAINER"
)

func main() {
if len(os.Args) < 2 {
log.Fatal(errors.New("invalid argument"))
Expand Down Expand Up @@ -171,8 +172,8 @@ func readAndRewrite(path string) error {
}
d := Data{
Maintainer: maintainer,
Year: time.Now().Year(),
Escape: sharpEscape,
Year: time.Now().Year(),
Escape: sharpEscape,
}
if fi.Name() == "LICENSE" {
err = license.Execute(buf, d)
Expand Down
12 changes: 9 additions & 3 deletions internal/errors/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,39 @@ package errors

var (

// gRPC

ErrgRPCClientConnectionClose = func(name string, err error) error {
// ErrGRPCClientConnectionClose represents a function to generate an error that the gRPC connection couldn't close.
ErrGRPCClientConnectionClose = func(name string, err error) error {
return Wrapf(err, "%s's gRPC connection close error", name)
}

// ErrInvalidGRPCPort represents a function to generate an error that the gRPC port is invalid.
ErrInvalidGRPCPort = func(addr, host string, port uint16) error {
return Errorf("invalid gRPC client connection port to addr: %s,\thost: %s\t port: %d", addr, host, port)
}

// ErrInvalidGRPCClientConn represents a function to generate an error that the vald internal gRPC connection is invalid.
ErrInvalidGRPCClientConn = func(addr string) error {
return Errorf("invalid gRPC client connection to %s", addr)
}

// ErrGRPCLookupIPAddrNotFound represents a function to generate an error that the vald internal gRPC client couldn't find IP address.
ErrGRPCLookupIPAddrNotFound = func(host string) error {
return Errorf("vald internal gRPC client could not find ip addrs for %s", host)
}

// ErrGRPCClientNotFound represents an error that the vald internal gRPC client couldn't find.
ErrGRPCClientNotFound = New("vald internal gRPC client not found")

// ErrGRPCClientConnNotFound represents a function to generate an error that the gRPC client connection couldn't find.
ErrGRPCClientConnNotFound = func(addr string) error {
return Errorf("gRPC client connection not found in %s", addr)
}

// ErrRPCCallFailed represents a function to generate an error that the RPC call failed.
ErrRPCCallFailed = func(addr string, err error) error {
return Wrapf(err, "addr: %s", addr)
}

// ErrGRPCTargetAddrNotFound represents an error that the gRPC target address couldn't find.
ErrGRPCTargetAddrNotFound = New("grpc connection target not found")
)
Loading

0 comments on commit 0e93f6b

Please sign in to comment.