-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat(SQS): custom quote query * lint * add test for ParseNumbers (cherry picked from commit 8214a60) Co-authored-by: Roman <roman@osmosis.team>
- Loading branch information
1 parent
13cc22c
commit dfe4e38
Showing
6 changed files
with
234 additions
and
0 deletions.
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,5 @@ | ||
package http | ||
|
||
func ParseNumbers(numbersParam string) ([]uint64, error) { | ||
return parseNumbers(numbersParam) | ||
} |
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,42 @@ | ||
package http_test | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/osmosis-labs/osmosis/v21/ingest/sqs/router/delivery/http" | ||
) | ||
|
||
// TestParseNumbers tests parsing a string of numbers to a slice of uint64 | ||
func TestParseNumbers(t *testing.T) { | ||
testCases := []struct { | ||
input string | ||
expectedNumbers []uint64 | ||
expectedError bool | ||
}{ | ||
{"", nil, false}, // Empty string, expecting an empty slice and no error | ||
{"1,2,3", []uint64{1, 2, 3}, false}, // Comma-separated numbers, expecting slice {1, 2, 3} and no error | ||
{"42", []uint64{42}, false}, // Single number, expecting slice {42} and no error | ||
{"10,20,30", []uint64{10, 20, 30}, false}, // Another set of numbers | ||
|
||
// Add more test cases as needed | ||
{"abc", nil, true}, // Invalid input, expecting an error | ||
} | ||
|
||
for _, testCase := range testCases { | ||
actualNumbers, actualError := http.ParseNumbers(testCase.input) | ||
|
||
if testCase.expectedError { | ||
require.Error(t, actualError) | ||
return | ||
} | ||
|
||
// Check if the actual output matches the expected output | ||
if !reflect.DeepEqual(actualNumbers, testCase.expectedNumbers) { | ||
t.Errorf("Input: %s, Expected Numbers: %v, Actual Numbers: %v", | ||
testCase.input, testCase.expectedNumbers, actualNumbers) | ||
} | ||
} | ||
} |
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