-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds throughput support for Cosmos DB Mongo Collection (#4467)
fixes #3586
- Loading branch information
Showing
5 changed files
with
158 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,100 @@ | ||
package validate | ||
|
||
import "testing" | ||
|
||
func TestCosmosAccountName(t *testing.T) { | ||
cases := []struct { | ||
Value string | ||
Errors int | ||
}{ | ||
{ | ||
Value: "foo-bar", | ||
Errors: 0, | ||
}, | ||
{ | ||
Value: "foo", | ||
Errors: 0, | ||
}, | ||
{ | ||
Value: "fu", | ||
Errors: 1, | ||
}, | ||
{ | ||
Value: "foo_bar", | ||
Errors: 1, | ||
}, | ||
{ | ||
Value: "fooB@r", | ||
Errors: 1, | ||
}, | ||
{ | ||
Value: "foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar", | ||
Errors: 1, | ||
}, | ||
} | ||
|
||
for _, tc := range cases { | ||
_, errors := CosmosAccountName(tc.Value, "throughput") | ||
if len(errors) != tc.Errors { | ||
t.Fatalf("Expected CosmosAccountName to trigger '%d' errors for '%s' - got '%d'", tc.Errors, tc.Value, len(errors)) | ||
} | ||
} | ||
} | ||
|
||
func TestCosmosEntityName(t *testing.T) { | ||
cases := []struct { | ||
Value string | ||
Errors int | ||
}{ | ||
{ | ||
Value: "", | ||
Errors: 1, | ||
}, | ||
{ | ||
Value: "someEntityName", | ||
Errors: 0, | ||
}, | ||
{ | ||
Value: "someEntityNamesomeEntityNamesomeEntityNamesomeEntityNamesomeEntityNamesomeEntityNamesomeEntityNamesomeEntityNamesomeEntityNamesomeEntityNamesomeEntityNamesomeEntityNamesomeEntityNamesomeEntityNamesomeEntityNamesomeEntityNamesomeEntityNamesomeEntityNamesomeEntityName", | ||
Errors: 1, | ||
}, | ||
} | ||
|
||
for _, tc := range cases { | ||
_, errors := CosmosEntityName(tc.Value, "throughput") | ||
if len(errors) != tc.Errors { | ||
t.Fatalf("Expected CosmosEntityName to trigger '%d' errors for '%s' - got '%d'", tc.Errors, tc.Value, len(errors)) | ||
} | ||
} | ||
} | ||
|
||
func TestCosmosThroughput(t *testing.T) { | ||
cases := []struct { | ||
Value int | ||
Errors int | ||
}{ | ||
{ | ||
Value: 400, | ||
Errors: 0, | ||
}, | ||
{ | ||
Value: 300, | ||
Errors: 1, | ||
}, | ||
{ | ||
Value: 450, | ||
Errors: 1, | ||
}, | ||
{ | ||
Value: 10000, | ||
Errors: 0, | ||
}, | ||
} | ||
|
||
for _, tc := range cases { | ||
_, errors := CosmosThroughput(tc.Value, "throughput") | ||
if len(errors) != tc.Errors { | ||
t.Fatalf("Expected CosmosThroughput to trigger '%d' errors for '%d' - got '%d'", tc.Errors, tc.Value, len(errors)) | ||
} | ||
} | ||
} |
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