Esempio n. 1
0
func TestCollection_Insert(t *testing.T) {
	bucket, _ := redis.NewBucket(config)

	adminUsers := collections.NewList("admins", bucket)
	adminUsers.Clean()

	adminUsers.Insert(admin)

	if adminUsers.Size() != 1 {
		t.Errorf("Want 1 got %d\n", adminUsers.Size())
	}
}
Esempio n. 2
0
func New(name string, config map[string]string) (*Stream, error) {
	stream := new(Stream)

	bucket, err := redis.NewBucket(config)
	if err != nil {
		return stream, err
	}

	listBucket := bucket.NewList(name)

	stream.Name = name
	stream.Notifier = NewPubsub(config)
	stream.ListBucket = listBucket

	return stream, nil
}
Esempio n. 3
0
func TestStorage_Datasets(t *testing.T) {
	bucket, _ := redis.NewBucket(config)

	dataset1 := storage.NewDataset("posts", bucket)
	dataset2 := storage.NewDataset("users", bucket)

	storage := storage.New(bucket)
	storage.Clean()

	storage.Insert(dataset1)
	storage.Insert(dataset2)

	datasets := storage.Datasets()

	if len(datasets) != 2 {
		t.Errorf("Want 2 got %d\n", len(datasets))
	}
}
Esempio n. 4
0
func TestDataset_Insert(t *testing.T) {
	bucket, _ := redis.NewBucket(config)

	dataset := storage.NewDataset("iris", bucket)
	dataset.Clean()

	col1 := collections.NewList("setosa", bucket)
	col2 := collections.NewHash("virginica", bucket)

	dataset.Insert(col1.Name, col1)
	dataset.Insert(col1.Name, col2)

	// TODO(datagentleman): will be fixed after Hash.All() will be implemented
	// collections := dataset.All()

	// if len(collections) != 2 {
	// 	t.Errorf("Want 2 got %d\n", len(collections))
	// }
}
Esempio n. 5
0
func (i *Instance) Marshal() []byte {
	value, _ := json.Marshal(i)
	return value
}

func (i *Instance) Key() string {
	return i.Attrs["Key"].(string)
}

var (
	config = map[string]string{
		"storage:address": "127.0.0.1:6379",
	}

	bucket, _ = redis.NewBucket(config)
	conn, err = bucket.Conn()

	attrs = instance.Attributes{
		"Key":  "user:1",
		"Name": "datagentleman",
		"Age":  30,
	}

	ins = &Instance{
		Attrs: attrs,
	}
)

func TestHash_Insert(t *testing.T) {
	if err != nil {