core_test.go 798 Bytes
Newer Older
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
package core

import (
  "testing"
  config "github.com/jbenet/go-ipfs/config"
)

func TestDatastores(t *testing.T) {

  good := []*config.Config {
    &config.Config{ Datastore: &config.Datastore{Type: "memory"} },
    &config.Config{ Datastore: &config.Datastore{Type: "leveldb", Path: ".testdb"} },
  }

  bad := []*config.Config {
    &config.Config{ Datastore: &config.Datastore{} },
    &config.Config{ Datastore: &config.Datastore{Type: "badtype"} },
    &config.Config{ },
    nil,
  }

  for i, c := range(good) {
    n, err := NewIpfsNode(c)
    if n == nil || err != nil {
      t.Error("Should have constructed.", i, err)
    }
  }

  for i, c := range(bad) {
    n, err := NewIpfsNode(c)
    if n != nil || err == nil {
      t.Error("Should have failed to construct.", i)
    }
  }
}