Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
DexterYan committed Nov 18, 2024
1 parent 90ef92a commit 4924334
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
14 changes: 5 additions & 9 deletions pkg/collect/host_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,12 @@ func isValidLoadBalancerAddress(address string) bool {

}

errs := validation.IsQualifiedName(hostAddress)
if len(errs) > 0 {
if len(hostAddress) < 255 {
err := validator.New().Var(hostAddress, "hostname_rfc1123")
return err == nil
} else {
return false
}
if len(hostAddress) > 255 {
return false
}
return len(errs) == 0

err = validator.New().Var(hostAddress, "hostname")
return err == nil
}

func checkTCPConnection(progressChan chan<- interface{}, listenAddress string, dialAddress string, timeout time.Duration) (NetworkStatus, error) {
Expand Down
11 changes: 3 additions & 8 deletions pkg/collect/host_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,13 @@ func Test_isValidLoadBalancerAddress(t *testing.T) {
want: false,
},
{
name: "Too many characters less than 64, rfc1123 not compliant",
args: args{address: "howlongcanwemakethiswithoutrunningoutofwordsbecasueweneedto.com:80"},
want: false,
},
{
name: "Too many characters less than 64, rfc1123 compliant",
args: args{address: "howlongcanwemakethiswithoutrunningoutofwordsbecasueweneedto.aws.com:80"},
name: "Too many characters less than 255",
args: args{address: "howlongcanwemakethiswithoutrunningoutofwordsbecasueweneedtohitatleast64.com:80"},
want: true,
},
{
name: "Too many characters bigger than 255",
args: args{address: "howlongcanwemakethiswithouthowlongcanwemakethiswithouthowlongcanwemakethiswithouthowlongcanwemakethiswithoutrunningoutofwordsbecasueweneedtohitatleast64howlongcanwemakethiswithouthowlongcanwemakethiswithouthowlongcanwemakethiswithouthowlongcanwemakethiswithoutrunningoutofwordsbecasueweneedtohitatleast64.com:80"},
args: args{address: "howlongcanwemakethiswithouthowlongcanwemakethiswithouthowlongcanwemakethiswithoutrunningoutofwordsbecasueweneedtohitatleast64howlongcanwemakethiswithouthowlongcanwemakethiswithouthowlongcanwemakethiswithoutrunningoutofwordsbecasueweneedtohitatleast64dssdfasdffs.com:80"},
want: false,
},
{
Expand Down

0 comments on commit 4924334

Please sign in to comment.