Feat: works on my machine
This commit is contained in:
38
test.go
Normal file
38
test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"gitea.konchin.com/ytshih/inp2025/utils"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var testCmd = &cobra.Command{
|
||||
Use: "test",
|
||||
}
|
||||
|
||||
var testServerCmd = &cobra.Command{
|
||||
Use: "server",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
dataCh := make(chan string)
|
||||
_, shutdown, err := utils.ListenUDPData(18787, dataCh)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer shutdown()
|
||||
<-dataCh
|
||||
},
|
||||
}
|
||||
|
||||
var testClientCmd = &cobra.Command{
|
||||
Use: "client",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
err := utils.Ping("localhost:18787")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
testCmd.AddCommand(testServerCmd)
|
||||
testCmd.AddCommand(testClientCmd)
|
||||
}
|
||||
Reference in New Issue
Block a user