test: added base for testing of api

api-testing
Jef Roosens 2022-05-08 18:27:29 +02:00
parent 230920576d
commit ab60292310
Signed by: Jef Roosens
GPG Key ID: B580B976584B5F30
2 changed files with 37 additions and 0 deletions

View File

@ -1,4 +1,5 @@
// Bindings for the libarchive library
module package
#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
}