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

View File

@@ -4,11 +4,12 @@ import os
import time import time
fn test_zinit() { fn test_zinit() {
this_dir := os.dir(@FILE)
// you need to have zinit in your path to run this test // 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) 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 ls := client.list()!
mut want_ls := { mut want_ls := {
@@ -57,4 +58,7 @@ fn test_zinit() {
time.sleep(time.millisecond * 10) time.sleep(time.millisecond * 10)
st = client.status('service_1')! st = client.status('service_1')!
assert st.state.contains('SIGTERM') assert st.state.contains('SIGTERM')
// Remove the socet file
os.rm('${this_dir}/zinit/zinit.sock')!
} }

View File

@@ -185,8 +185,6 @@ clients/livekit
' '
tests_error := ' tests_error := '
osal/package_test.v
rpc_test.v
screen_test.v screen_test.v
tmux_session_test.v tmux_session_test.v
tmux_window_test.v tmux_window_test.v