config_test.go 434 Bytes
Newer Older
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
1 2 3
package config

import (
Juan Batiz-Benet's avatar
gofmt  
Juan Batiz-Benet committed
4
	"testing"
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
5 6 7
)

func TestConfig(t *testing.T) {
Brian Tiger Chow's avatar
Brian Tiger Chow committed
8
	const filename = ".ipfsconfig"
9
	const dsPath = "/path/to/datastore"
Brian Tiger Chow's avatar
Brian Tiger Chow committed
10
	cfgWritten := new(Config)
11
	cfgWritten.Datastore.Path = dsPath
Brian Tiger Chow's avatar
Brian Tiger Chow committed
12 13 14 15 16
	err := WriteConfigFile(filename, cfgWritten)
	if err != nil {
		t.Error(err)
	}
	cfgRead, err := Load(filename)
Juan Batiz-Benet's avatar
gofmt  
Juan Batiz-Benet committed
17 18 19 20
	if err != nil {
		t.Error(err)
		return
	}
21 22 23
	if cfgWritten.Datastore.Path != cfgRead.Datastore.Path {
		t.Fail()
	}
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
24
}