Example #1
0
func TestIsCouchDBEnabled(t *testing.T) {
	setUpCoreYAMLConfig()
	defer testutil.ResetConfigToDefaultValues()
	viper.Set("ledger.state.stateDatabase", "CouchDB")
	updatedValue := IsCouchDBEnabled()
	testutil.AssertEquals(t, updatedValue, true) //test config returns true
}
Example #2
0
func TestIsHistoryDBEnabledWhenOnlyCouchDBEnabled(t *testing.T) {
	setUpCoreYAMLConfig()
	defer testutil.ResetConfigToDefaultValues()
	viper.Set("ledger.state.stateDatabase", "CouchDB")
	viper.Set("ledger.state.historyDatabase", false)
	updatedValue := IsHistoryDBEnabled()
	testutil.AssertEquals(t, updatedValue, false) //test config is false
}
Example #3
0
func TestGetCouchDBDefinition(t *testing.T) {
	setUpCoreYAMLConfig()
	defer testutil.ResetConfigToDefaultValues()
	viper.Set("ledger.state.stateDatabase", "CouchDB")
	couchDBDef := GetCouchDBDefinition()
	testutil.AssertEquals(t, couchDBDef.URL, "127.0.0.1:5984")
	testutil.AssertEquals(t, couchDBDef.Username, "")
	testutil.AssertEquals(t, couchDBDef.Password, "")
}
Example #4
0
func TestIsCouchDBEnabledDefault(t *testing.T) {
	setUpCoreYAMLConfig()
	// During a build the default values should be false.

	// If the  ledger test are run with CouchDb enabled, need to provide a mechanism
	// To let this test run but still test default values.
	if IsCouchDBEnabled() == true {
		testutil.ResetConfigToDefaultValues()
		defer viper.Set("ledger.state.stateDatabase", "CouchDB")
	}
	defaultValue := IsCouchDBEnabled()
	testutil.AssertEquals(t, defaultValue, false) //test default config is false
}