test: Fix rpc_test file

This commit is contained in:
Mahmoud Emad
2025-01-26 17:15:04 +02:00
committed by mariobassem
parent 266205363d
commit 85ac9e5104
3 changed files with 9 additions and 6 deletions

View File

@@ -5,7 +5,7 @@ fn setup() !&redisclient.Redis {
mut redis := redisclient.core_get()!
// Select db 10 to be away from default one '0'
redis.selectdb(10) or { panic(err) }
return &redis
return redis
}
fn cleanup(mut redis redisclient.Redis) ! {
@@ -25,7 +25,8 @@ fn test_rpc() {
mut r := redis.rpc_get('testrpc')
r.call(cmd: 'test.cmd', data: 'this is my data, normally json', wait: false)!
returnqueue := r.process(10000, process_test)!
returnqueue := r.process(process_test, timeout: 10000)!
mut res := r.result(10000, returnqueue)!
console.print_debug(res)

View File

@@ -4,11 +4,12 @@ import os
import time
fn test_zinit() {
this_dir := os.dir(@FILE)
// you need to have zinit in your path to run this test
spawn os.execute('zinit -s herolib/osal/zinit/zinit/zinit.sock init -c herolib/osal/zinit/zinit')
spawn os.execute('zinit -s ${this_dir}/zinit/zinit.sock init -c ${this_dir}/zinit')
time.sleep(time.second)
client := new_rpc_client('herolib/osal/zinit/zinit/zinit.sock')
client := new_rpc_client(socket_path: '${this_dir}/zinit/zinit.sock')
mut ls := client.list()!
mut want_ls := {
@@ -57,4 +58,7 @@ fn test_zinit() {
time.sleep(time.millisecond * 10)
st = client.status('service_1')!
assert st.state.contains('SIGTERM')
// Remove the socet file
os.rm('${this_dir}/zinit/zinit.sock')!
}