forked from jmpsec/osctrl
-
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.
Update the way of creating distributed query in osctrl-api
- Loading branch information
1 parent
6c261f3
commit 370977b
Showing
4 changed files
with
85 additions
and
54 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
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 |
---|---|---|
@@ -1,27 +1,44 @@ | ||
package utils | ||
package utils_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/jmpsec/osctrl/utils" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestBytesReceivedConversionBytes(t *testing.T) { | ||
assert.NotEmpty(t, BytesReceivedConversion(123)) | ||
assert.Equal(t, "123 bytes", BytesReceivedConversion(123)) | ||
assert.NotEmpty(t, utils.BytesReceivedConversion(123)) | ||
assert.Equal(t, "123 bytes", utils.BytesReceivedConversion(123)) | ||
} | ||
|
||
func TestBytesReceivedConversionKBytes(t *testing.T) { | ||
assert.NotEmpty(t, BytesReceivedConversion(1024)) | ||
assert.Equal(t, "1.0 KB", BytesReceivedConversion(1024)) | ||
assert.NotEmpty(t, utils.BytesReceivedConversion(1024)) | ||
assert.Equal(t, "1.0 KB", utils.BytesReceivedConversion(1024)) | ||
} | ||
|
||
func TestBytesReceivedConversionMBytes(t *testing.T) { | ||
assert.NotEmpty(t, BytesReceivedConversion(1048576)) | ||
assert.Equal(t, "1.0 MB", BytesReceivedConversion(1048576)) | ||
assert.NotEmpty(t, utils.BytesReceivedConversion(1048576)) | ||
assert.Equal(t, "1.0 MB", utils.BytesReceivedConversion(1048576)) | ||
} | ||
|
||
func TestRandomForNames(t *testing.T) { | ||
assert.NotEmpty(t, RandomForNames()) | ||
assert.Equal(t, 32, len(RandomForNames())) | ||
assert.NotEmpty(t, utils.RandomForNames()) | ||
assert.Equal(t, 32, len(utils.RandomForNames())) | ||
} | ||
|
||
func TestIntersect(t *testing.T) { | ||
var slice1 = []uint{1, 2, 3, 4, 5} | ||
var slice2 = []uint{3, 4, 5, 6, 7} | ||
var expected = []uint{3, 4, 5} | ||
assert.Equal(t, expected, utils.Intersect(slice1, slice2)) | ||
slice1 = utils.Intersect(slice1, slice2) | ||
assert.Equal(t, expected, slice1) | ||
} | ||
|
||
func TestIntersectEmpty(t *testing.T) { | ||
var slice1 = []uint{} | ||
var slice2 = []uint{3, 4, 5, 6, 7} | ||
var expected = []uint{3, 4, 5, 6, 7} | ||
assert.Equal(t, expected, utils.Intersect(slice1, slice2)) | ||
} |