Skip to content

Commit

Permalink
Remove old datastore key unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewSisley committed Jul 8, 2024
1 parent 4c450c0 commit 0488b30
Showing 1 changed file with 0 additions and 80 deletions.
80 changes: 0 additions & 80 deletions internal/core/key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,86 +34,6 @@ func TestNewDataStoreKey_ReturnsEmptyStruct_GivenEmptyString(t *testing.T) {
assert.ErrorIs(t, ErrEmptyKey, err)
}

func TestNewDataStoreKey_ReturnsCollectionIdAndIndexIdAndDocIDAndFieldIdAndInstanceType_GivenFourItemsWithType(
t *testing.T,
) {
instanceType := "anyType"
fieldID := "f1"
docID := "docID"
var collectionRootID uint32 = 2
inputString := fmt.Sprintf("%v/%s/%s/%s", collectionRootID, instanceType, docID, fieldID)

result, err := NewDataStoreKey(inputString)
if err != nil {
t.Error(err)
}
resultString := result.ToString()

assert.Equal(
t,
DataStoreKey{
CollectionRootID: collectionRootID,
DocID: docID,
FieldID: fieldID,
InstanceType: InstanceType(instanceType)},
result)
assert.Equal(t, fmt.Sprintf("/%v/%s/%s/%s", collectionRootID, instanceType, docID, fieldID), resultString)
}

func TestNewDataStoreKey_ReturnsEmptyStruct_GivenAStringWithMissingElements(t *testing.T) {
inputString := "/0/v"

_, err := NewDataStoreKey(inputString)

assert.ErrorIs(t, ErrInvalidKey, err)
}

func TestNewDataStoreKey_GivenAShortObjectMarker(t *testing.T) {
instanceType := "anyType"
docID := "docID"
var collectionRootID uint32 = 2
inputString := fmt.Sprintf("%v/%s/%s", collectionRootID, instanceType, docID)

result, err := NewDataStoreKey(inputString)
if err != nil {
t.Error(err)
}
resultString := result.ToString()

assert.Equal(
t,
DataStoreKey{
CollectionRootID: collectionRootID,
DocID: docID,
InstanceType: InstanceType(instanceType)},
result)
assert.Equal(t, fmt.Sprintf("/%v/%s/%s", collectionRootID, instanceType, docID), resultString)
}

func TestNewDataStoreKey_GivenAStringWithExtraPrefixes(t *testing.T) {
instanceType := "anyType"
fieldId := "f1"
docID := "docID"
collectionId := "1"
inputString := "/db/my_database_name/data/" + collectionId + "/" + instanceType + "/" + docID + "/" + fieldId

_, err := NewDataStoreKey(inputString)

assert.ErrorIs(t, ErrInvalidKey, err)
}

func TestNewDataStoreKey_GivenAStringWithExtraSuffix(t *testing.T) {
instanceType := "anyType"
fieldId := "f1"
docID := "docID"
collectionId := "1"
inputString := "/db/data/" + collectionId + "/" + instanceType + "/" + docID + "/" + fieldId + "/version_number"

_, err := NewDataStoreKey(inputString)

assert.ErrorIs(t, ErrInvalidKey, err)
}

func TestNewIndexKey_IfEmptyParam_ReturnPrefix(t *testing.T) {
key := NewCollectionIndexKey(immutable.None[uint32](), "")
assert.Equal(t, "/collection/index", key.ToString())
Expand Down

0 comments on commit 0488b30

Please sign in to comment.