-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jesse Schmidt
committed
Jun 13, 2024
1 parent
419a1b5
commit 089105e
Showing
2 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//go:build unit | ||
|
||
package cmd | ||
|
||
import ( | ||
"asvec/cmd/flags" | ||
"testing" | ||
|
||
avs "github.com/aerospike/aerospike-proximus-client-go" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestParseBothHostSeedsFlag(t *testing.T) { | ||
testCases := []struct { | ||
seeds *flags.SeedsSliceFlag | ||
host *flags.HostPortFlag | ||
expectedSlice avs.HostPortSlice | ||
expectedIsLoadBalancer bool | ||
}{ | ||
{ | ||
&flags.SeedsSliceFlag{ | ||
Seeds: avs.HostPortSlice{ | ||
avs.NewHostPort("1.1.1.1", 5000, false), | ||
}, | ||
}, | ||
flags.NewDefaultHostPortFlag(), | ||
avs.HostPortSlice{ | ||
avs.NewHostPort("1.1.1.1", 5000, false), | ||
}, | ||
false, | ||
}, | ||
{ | ||
&flags.SeedsSliceFlag{ | ||
Seeds: avs.HostPortSlice{}, | ||
}, | ||
flags.NewDefaultHostPortFlag(), | ||
avs.HostPortSlice{ | ||
&flags.NewDefaultHostPortFlag().HostPort, | ||
}, | ||
true, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
actualSlice, actualBool := parseBothHostSeedsFlag(tc.seeds, tc.host) | ||
assert.Equal(t, tc.expectedSlice, actualSlice) | ||
assert.Equal(t, tc.expectedIsLoadBalancer, actualBool) | ||
} | ||
} |