Skip to content

Commit

Permalink
go format + used StringP arg for command
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmikwolf committed Dec 16, 2024
1 parent 15b197a commit 7872d22
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions cmd/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
)

const (
defaultDNSPort = 53
defaultIPAddress = "127.0.0.1"
defaultDNSPort = 53
defaultIPAddress = "127.0.0.1"
)

func NewHealthcheckCommand() *cobra.Command {
Expand All @@ -21,7 +21,7 @@ func NewHealthcheckCommand() *cobra.Command {
}

c.Flags().Uint16P("port", "p", defaultDNSPort, "blocky port")
c.Flags().String("bindip", defaultIPAddress, "blocky host binding ip address")
c.Flags().StringP("bindip", "b", defaultIPAddress, "blocky host binding ip address")

return c
}
Expand Down
16 changes: 8 additions & 8 deletions cmd/healthcheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ var _ = Describe("Healthcheck command", func() {
})

It("should succeed", func() {
port := helpertest.GetStringPort(5100)
ip := "127.0.0.1"
srv := createMockServer(ip, port)
ip := "127.0.0.1"
hostPort := helpertest.GetHostPort(ip, 65100)
port := helpertest.GetStringPort(65100)
srv := createMockServer(hostPort)
go func() {
defer GinkgoRecover()
err := srv.ListenAndServe()
Expand All @@ -42,22 +43,21 @@ var _ = Describe("Healthcheck command", func() {

Eventually(func() error {
c := NewHealthcheckCommand()
c.SetArgs([]string{"-p", port})
c.SetArgs([]string{"--bindip", ip})
c.SetArgs([]string{"-p", port, "-b", ip})

return c.Execute()
}, "1s").Should(Succeed())
})
})
})

func createMockServer(ip string, port string) *dns.Server {
func createMockServer(hostPort string) *dns.Server {
res := &dns.Server{
Addr: ip + ":" + port,
Addr: hostPort,
Net: "tcp",
Handler: dns.NewServeMux(),
NotifyStartedFunc: func() {
fmt.Println("Mock healthcheck server is up")
fmt.Printf("Mock healthcheck server is up: %s\n", hostPort)
},
}

Expand Down

0 comments on commit 7872d22

Please sign in to comment.