forked from Azure/azure-sdk-for-go
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add API for creating hierarchical
PartitionKey
s (Azure#23577)
Co-authored-by: Joel Hendrix <[email protected]> Co-authored-by: Ashley Stanton-Nurse <[email protected]>
- Loading branch information
1 parent
b392016
commit 058b4f1
Showing
6 changed files
with
346 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
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package azcosmos | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestPartitionKeyDefinitionSerialization(t *testing.T) { | ||
pkd_kind_unset_len_one := PartitionKeyDefinition{ | ||
Paths: []string{"somePath"}, | ||
Version: 2, | ||
} | ||
|
||
jsonString, err := pkd_kind_unset_len_one.MarshalJSON() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
expected := `{"kind":"Hash","paths":["somePath"],"version":2}` | ||
if string(jsonString) != expected { | ||
t.Errorf("Expected serialization %v, but got %v", expected, string(jsonString)) | ||
} | ||
|
||
pkd_kind_unset_len_two := PartitionKeyDefinition{ | ||
Paths: []string{"somePath", "someOtherPath"}, | ||
Version: 2, | ||
} | ||
|
||
jsonString, err = pkd_kind_unset_len_two.MarshalJSON() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
expected = `{"kind":"MultiHash","paths":["somePath","someOtherPath"],"version":2}` | ||
if string(jsonString) != expected { | ||
t.Errorf("Expected serialization %v, but got %v", expected, string(jsonString)) | ||
} | ||
|
||
pkd_kind_set := PartitionKeyDefinition{ | ||
Kind: PartitionKeyKindMultiHash, | ||
Paths: []string{"somePath"}, | ||
Version: 2, | ||
} | ||
|
||
jsonString, err = pkd_kind_set.MarshalJSON() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
expected = `{"kind":"MultiHash","paths":["somePath"],"version":2}` | ||
if string(jsonString) != expected { | ||
t.Errorf("Expected serialization %v, but got %v", expected, string(jsonString)) | ||
} | ||
} |
Oops, something went wrong.