Compare commits

...

1 Commits

Author SHA1 Message Date
Jef Roosens ab60292310
test: added base for testing of api 2022-05-08 18:27:29 +02:00
2 changed files with 37 additions and 0 deletions

View File

@ -1,4 +1,5 @@
// Bindings for the libarchive library // Bindings for the libarchive library
module package
#flag -larchive #flag -larchive

View File

@ -0,0 +1,36 @@
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
}