github.com/TrueBlocks/trueblocks-core/src/apps/chifra@v0.0.0-20241022031540-b362680128f7/pkg/config/config_test.go (about) 1 // Copyright 2021 The TrueBlocks Authors. All rights reserved. 2 // Use of this source code is governed by a license that can 3 // be found in the LICENSE file. 4 5 package config 6 7 import ( 8 "os" 9 "testing" 10 11 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/utils" 12 ) 13 14 func Test_ReadTrueBlocks(t *testing.T) { 15 if len(GetSettings().CachePath) == 0 { 16 t.Error("CachePath is empty") 17 } 18 if GetSettings().CachePath[len(GetSettings().CachePath)-1] == os.PathSeparator { 19 // the user's path may end with a slash, but the returned path does not 20 ret := PathToCache(utils.GetTestChain()) 21 if len(ret) > 0 && ret[len(ret)-1] == os.PathSeparator { 22 t.Error("CachePath ends with a '/'. It should not.") 23 } 24 } 25 if GetSettings().CachePath[0] != os.PathSeparator { 26 t.Error("CachePath is not an absolute path") 27 } 28 if len(GetSettings().IndexPath) == 0 { 29 t.Error("IndexPath is empty") 30 } 31 if GetSettings().IndexPath[len(GetSettings().IndexPath)-1] == os.PathSeparator { 32 // the user's path may end with a slash, but the returned path does not 33 ret := PathToIndex(utils.GetTestChain()) 34 if len(ret) > 0 && ret[len(ret)-1] == string(os.PathSeparator)[0] { 35 t.Error("IndexPath ends with a '/'. It should not.") 36 } 37 } 38 settings := GetSettings() 39 if settings.IndexPath[0] != os.PathSeparator { 40 t.Error("IndexPath is not an absolute path") 41 } 42 if len(GetSettings().DefaultChain) == 0 { 43 t.Error("DefaultChain is empty.") 44 } 45 }