From ab60292310f475a21910f6adfdad19376d5817a8 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Sun, 8 May 2022 18:27:29 +0200 Subject: [PATCH] test: added base for testing of api --- src/{ => package}/archive.c.v | 1 + src/server/git_test.v | 36 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) rename src/{ => package}/archive.c.v (99%) create mode 100644 src/server/git_test.v diff --git a/src/archive.c.v b/src/package/archive.c.v similarity index 99% rename from src/archive.c.v rename to src/package/archive.c.v index 1f0d1dd..d8fccd2 100644 --- a/src/archive.c.v +++ b/src/package/archive.c.v @@ -1,4 +1,5 @@ // Bindings for the libarchive library +module package #flag -larchive diff --git a/src/server/git_test.v b/src/server/git_test.v new file mode 100644 index 0000000..05ac6fc --- /dev/null +++ b/src/server/git_test.v @@ -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 +}