test: added base for testing of api
parent
230920576d
commit
ab60292310
|
@ -1,4 +1,5 @@
|
|||
// Bindings for the libarchive library
|
||||
module package
|
||||
|
||||
#flag -larchive
|
||||
|
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue