core_test.go 745 Bytes
Newer Older
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
1 2 3
package core

import (
Juan Batiz-Benet's avatar
go fmt  
Juan Batiz-Benet committed
4 5
	config "github.com/jbenet/go-ipfs/config"
	"testing"
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
6 7 8 9
)

func TestDatastores(t *testing.T) {

Juan Batiz-Benet's avatar
go fmt  
Juan Batiz-Benet committed
10 11 12 13
	good := []*config.Config{
		&config.Config{Datastore: &config.Datastore{Type: "memory"}},
		&config.Config{Datastore: &config.Datastore{Type: "leveldb", Path: ".testdb"}},
	}
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
14

Juan Batiz-Benet's avatar
go fmt  
Juan Batiz-Benet committed
15 16 17 18 19 20
	bad := []*config.Config{
		&config.Config{Datastore: &config.Datastore{}},
		&config.Config{Datastore: &config.Datastore{Type: "badtype"}},
		&config.Config{},
		nil,
	}
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
21

Juan Batiz-Benet's avatar
go fmt  
Juan Batiz-Benet committed
22 23 24 25 26 27
	for i, c := range good {
		n, err := NewIpfsNode(c)
		if n == nil || err != nil {
			t.Error("Should have constructed.", i, err)
		}
	}
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
28

Juan Batiz-Benet's avatar
go fmt  
Juan Batiz-Benet committed
29 30 31 32 33 34
	for i, c := range bad {
		n, err := NewIpfsNode(c)
		if n != nil || err == nil {
			t.Error("Should have failed to construct.", i)
		}
	}
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
35
}