Skip to content

Commit

Permalink
Remove deserialization tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pietrrrek committed Oct 28, 2024
1 parent 38037a6 commit 6c9f657
Showing 1 changed file with 0 additions and 89 deletions.
89 changes: 0 additions & 89 deletions sdk/data/azcosmos/partition_key_definition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package azcosmos

import (
"reflect"
"testing"
)

Expand Down Expand Up @@ -55,91 +54,3 @@ func TestPartitionKeyDefinitionSerialization(t *testing.T) {
t.Errorf("Expected serialization %v, but got %v", expected, string(jsonString))
}
}

func TestPartitionKeyDefinitionDeserialization(t *testing.T) {
def := PartitionKeyDefinition{
Paths: []string{"somePath"},
Version: 2,
}

jsonString, err := def.MarshalJSON()
if err != nil {
t.Fatal(err)
}

var otherDef PartitionKeyDefinition
err = otherDef.UnmarshalJSON(jsonString)

if err != nil {
t.Fatal(err, string(jsonString))
}

// Kind is inferred based on the number of paths
if otherDef.Kind != PartitionKeyKindHash {
t.Errorf("Expected Kind to be %v, but got %v", def.Kind, otherDef.Kind)
}

if !reflect.DeepEqual(def.Paths, otherDef.Paths) {
t.Errorf("Expected Paths to be %v, but got %v", def.Paths, otherDef.Paths)
}

if def.Version != otherDef.Version {
t.Errorf("Expected Version to be %v, but got %v", def.Version, otherDef.Version)
}

def = PartitionKeyDefinition{
Paths: []string{"somePath", "someOtherPath"},
Version: 2,
}

jsonString, err = def.MarshalJSON()
if err != nil {
t.Fatal(err)
}

err = otherDef.UnmarshalJSON(jsonString)
if err != nil {
t.Fatal(err, string(jsonString))
}

// Kind is inferred based on the number of paths
if otherDef.Kind != PartitionKeyKindMultiHash {
t.Errorf("Expected Kind to be %v, but got %v", PartitionKeyKindMultiHash, otherDef.Kind)
}

if !reflect.DeepEqual(def.Paths, otherDef.Paths) {
t.Errorf("Expected Paths to be %v, but got %v", def.Paths, otherDef.Paths)
}

if def.Version != otherDef.Version {
t.Errorf("Expected Version to be %v, but got %v", def.Version, otherDef.Version)
}

def = PartitionKeyDefinition{
Kind: PartitionKeyKindMultiHash,
Paths: []string{"somePath"},
Version: 2,
}

jsonString, err = def.MarshalJSON()
if err != nil {
t.Fatal(err)
}

err = otherDef.UnmarshalJSON(jsonString)
if err != nil {
t.Fatal(err, string(jsonString))
}

if def.Kind != otherDef.Kind {
t.Errorf("Expected Kind to be %v, but got %v", def.Kind, otherDef.Kind)
}

if !reflect.DeepEqual(def.Paths, otherDef.Paths) {
t.Errorf("Expected Paths to be %v, but got %v", def.Paths, otherDef.Paths)
}

if def.Version != otherDef.Version {
t.Errorf("Expected Version to be %v, but got %v", def.Version, otherDef.Version)
}
}

0 comments on commit 6c9f657

Please sign in to comment.