forked from vieter-v/vieter
37 lines
682 B
V
37 lines
682 B
V
module server
|
|
|
|
import os
|
|
import net.http
|
|
import io.util as io_util
|
|
import time
|
|
|
|
fn launch_server() ? {
|
|
tmp_dir := io_util.temp_dir() ?
|
|
conf := Config{
|
|
pkg_dir: os.join_path_single(tmp_dir, 'pkgs')
|
|
data_dir: tmp_dir
|
|
api_key: 'testing'
|
|
default_arch: 'x86_64'
|
|
}
|
|
|
|
go server(conf)
|
|
|
|
for waiting_cycles := 0; waiting_cycles < 50; waiting_cycles++ {
|
|
time.sleep(100 * time.millisecond)
|
|
http.get('http://127.0.0.1:$port') or { continue }
|
|
break
|
|
}
|
|
}
|
|
|
|
fn test_git_api() ? {
|
|
launch_server() ?
|
|
|
|
assert http.get('http://localhost:$port') ?.status_code == 404
|
|
}
|
|
|
|
fn test_something_api() ? {
|
|
launch_server() ?
|
|
|
|
assert http.get('http://localhost:$port') ?.status_code == 404
|
|
}
|