Skip to content
Snippets Groups Projects
main_test.go 1.07 KiB
Newer Older
  • Learn to ignore specific revisions
  • Ashwin's avatar
    Ashwin committed
    package main
    
    import (
    
    Ashwin's avatar
    Ashwin committed
    	"bufio"
    
    Ashwin's avatar
    Ashwin committed
    	"io/ioutil"
    	"os"
    	"testing"
    
    	"github.com/Sirupsen/logrus"
    	"github.com/dgraph-io/dgraph/commit"
    	"github.com/dgraph-io/dgraph/loader"
    	"github.com/dgraph-io/dgraph/posting"
    	"github.com/dgraph-io/dgraph/store"
    	"github.com/dgraph-io/dgraph/uid"
    	"github.com/dgryski/go-farm"
    )
    
    func TestQuery(t *testing.T) {
    	logrus.SetLevel(logrus.DebugLevel)
    	dir, err := ioutil.TempDir("", "storetest_")
    	dir1, err1 := ioutil.TempDir("", "storetest1_")
    	if err != nil || err1 != nil {
    		t.Error(err)
    		return
    	}
    	defer os.RemoveAll(dir)
    	defer os.RemoveAll(dir1)
    
    	ps := new(store.Store)
    	ps.Init(dir)
    
    	ps1 := new(store.Store)
    	ps1.Init(dir1)
    
    	clog := commit.NewLogger(dir, "mutations", 50<<20)
    	clog.Init()
    	defer clog.Close()
    	posting.Init(clog)
    
    	uid.Init(ps)
    	loader.Init(ps, ps1)
    
    
    Ashwin's avatar
    Ashwin committed
    	f, err := os.Open("test_input")
    	r := bufio.NewReader(f)
    	count, err := loader.HandleRdfReader(r, 1, 2)
    	t.Logf("count", count)
    
    Ashwin's avatar
    Ashwin committed
    
    
    Ashwin's avatar
    Ashwin committed
    	posting.MergeLists(100)
    
    Ashwin's avatar
    Ashwin committed
    
    
    Ashwin's avatar
    Ashwin committed
    	if farm.Fingerprint64([]byte("follows"))%2 == 1 {
    		if count != 4 {
    			t.Error("loader assignment not as expected")
    
    Ashwin's avatar
    Ashwin committed
    		}
    	}
    }