exposed init() to use in tests
This commit is contained in:
parent
0388c9249b
commit
324aeb7cac
@ -18,7 +18,7 @@ import spinner
|
|||||||
import tree_events
|
import tree_events
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let forest = init()
|
let forest = init("./treevault.json")
|
||||||
|
|
||||||
io.println(
|
io.println(
|
||||||
"Hello from Treevault! 🌳\n
|
"Hello from Treevault! 🌳\n
|
||||||
@ -29,8 +29,8 @@ pub fn main() {
|
|||||||
read_next(forest)
|
read_next(forest)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init() {
|
pub fn init(config_path) {
|
||||||
let config = config.load("./config.json") |> io.debug
|
let config = config.load(config_path) |> io.debug
|
||||||
let forest = case forest.load(config.snapshots_path, config.forest) {
|
let forest = case forest.load(config.snapshots_path, config.forest) {
|
||||||
Error(err) -> {
|
Error(err) -> {
|
||||||
let reason = err |> string.inspect
|
let reason = err |> string.inspect
|
||||||
|
|||||||
@ -9,7 +9,7 @@ pub fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn server_test() {
|
pub fn server_test() {
|
||||||
process.start(fn() { treevault.init() }, True)
|
process.start(fn() { treevault.init("non-existent-file.json") }, True)
|
||||||
process.sleep(2000)
|
process.sleep(2000)
|
||||||
|
|
||||||
let assert Ok(socket) =
|
let assert Ok(socket) =
|
||||||
|
|||||||
@ -73,7 +73,7 @@ pub fn json_test() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn config_test() {
|
pub fn config_test() {
|
||||||
let config = config.load("./test/vault.json")
|
let config = config.load("./test/treevault.json")
|
||||||
should.equal(
|
should.equal(
|
||||||
config.Config("./test/snapshots", 12_345, [
|
config.Config("./test/snapshots", 12_345, [
|
||||||
"tree0", "tree1", "tree2", "tree3", "tree4", "tree5", "tree6", "tree7",
|
"tree0", "tree1", "tree2", "tree3", "tree4", "tree5", "tree6", "tree7",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user