...

Source file src/edge-infra.dev/pkg/edge/datasync/cushion/storage_test.go

Documentation: edge-infra.dev/pkg/edge/datasync/cushion

     1  package cushion_test
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  
     7  	"github.com/go-kivik/kivik/v4"
     8  	"github.com/stretchr/testify/assert"
     9  
    10  	"edge-infra.dev/pkg/edge/chariot"
    11  	"edge-infra.dev/pkg/edge/datasync/cushion"
    12  )
    13  
    14  func TestPutWithEmptyObjects(t *testing.T) {
    15  	storage := cushion.NewCouchDBStorage(&kivik.Client{}, nil)
    16  	info, err := storage.Put(context.Background(), &kivik.DB{}, []chariot.StorageObject{}...)
    17  	assert.NoError(t, err)
    18  	assert.True(t, info.ObjectsEmpty)
    19  }
    20  
    21  func TestPutWithMultipleObjects(t *testing.T) {
    22  	storage := cushion.NewCouchDBStorage(&kivik.Client{}, nil)
    23  	_, err := storage.Put(context.Background(), &kivik.DB{}, chariot.StorageObject{}, chariot.StorageObject{})
    24  	assert.Error(t, err)
    25  }
    26  
    27  func TestDeleteWithEmptyObjects(t *testing.T) {
    28  	storage := cushion.NewCouchDBStorage(&kivik.Client{}, nil)
    29  	info, err := storage.Delete(context.Background(), &kivik.DB{}, []chariot.StorageObject{}...)
    30  	assert.NoError(t, err)
    31  	assert.True(t, info.ObjectsEmpty)
    32  }
    33  
    34  func TestDeleteWithMultipleObjects(t *testing.T) {
    35  	storage := cushion.NewCouchDBStorage(&kivik.Client{}, nil)
    36  	_, err := storage.Delete(context.Background(), &kivik.DB{}, chariot.StorageObject{}, chariot.StorageObject{})
    37  	assert.Error(t, err)
    38  }
    39  

View as plain text