Add sys action tests

next
Sayan Nandan 3 years ago
parent 832da79e9d
commit 5054adc33c
No known key found for this signature in database
GPG Key ID: 8BC07A0A4D41DD52

12
Cargo.lock generated

@ -538,9 +538,9 @@ dependencies = [
[[package]]
name = "getrandom"
version = "0.2.5"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77"
checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad"
dependencies = [
"cfg-if",
"libc",
@ -1350,7 +1350,7 @@ dependencies = [
[[package]]
name = "skytable"
version = "0.7.0-alpha.4"
source = "git+https://github.com/skytable/client-rust?branch=next#6d1affbc5a0ec9c9d4a1cb98f6542962fef6aac1"
source = "git+https://github.com/skytable/client-rust?branch=next#0fead63b0f5e80cef6106dd56e833812091aceeb"
dependencies = [
"async-trait",
"bb8",
@ -1364,7 +1364,7 @@ dependencies = [
[[package]]
name = "skytable"
version = "0.7.0-alpha.4"
source = "git+https://github.com/skytable/client-rust.git#6d1affbc5a0ec9c9d4a1cb98f6542962fef6aac1"
source = "git+https://github.com/skytable/client-rust.git#0fead63b0f5e80cef6106dd56e833812091aceeb"
dependencies = [
"r2d2",
]
@ -1426,9 +1426,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
[[package]]
name = "syn"
version = "1.0.89"
version = "1.0.90"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea297be220d52398dcc07ce15a209fce436d361735ac1db700cab3b6cdfb9f54"
checksum = "704df27628939572cd88d33f171cd6f896f4eaca85252c6e0a72d8d8287ee86f"
dependencies = [
"proc-macro2",
"quote",

@ -60,7 +60,7 @@ use core::slice;
/// The Skyhash protocol version
pub const PROTOCOL_VERSION: f32 = 1.2;
/// The Skyhash protocol version string (Skyhash-x.y)
pub const PROTOCOL_VERSIONSTRING: &[u8] = b"Skyhash-1.1";
pub const PROTOCOL_VERSIONSTRING: &str = "Skyhash-1.1";
const ASCII_UNDERSCORE: u8 = b'_';
const ASCII_AMPERSAND: u8 = b'&';

@ -49,3 +49,87 @@ mod tls {
);
}
}
mod sys {
use crate::protocol::{PROTOCOL_VERSION, PROTOCOL_VERSIONSTRING};
use libsky::VERSION;
use sky_macros::dbtest_func as dbtest;
use skytable::{query, Element, RespCode};
const UNKNOWN_ACTION: &str = "Unknown action";
#[dbtest]
async fn test_sys_unknown_action() {
runeq!(
con,
query!("sys", "what"),
Element::RespCode(RespCode::ErrorString(UNKNOWN_ACTION.to_owned()))
);
}
#[dbtest]
async fn test_sys_info_aerr() {
runeq!(
con,
query!("sys", "info"),
Element::RespCode(RespCode::ActionError)
);
runeq!(
con,
query!(
"sys",
"info",
"this is cool",
"but why this extra argument?"
),
Element::RespCode(RespCode::ActionError)
)
}
#[dbtest]
async fn test_sys_info_protocol() {
runeq!(
con,
query!("sys", "info", "protocol"),
Element::String(PROTOCOL_VERSIONSTRING.to_owned())
)
}
#[dbtest]
async fn test_sys_info_protover() {
runeq!(
con,
query!("sys", "info", "protover"),
Element::Float(PROTOCOL_VERSION)
)
}
#[dbtest]
async fn test_sys_info_version() {
runeq!(
con,
query!("sys", "info", "version"),
Element::String(VERSION.to_owned())
)
}
#[dbtest]
async fn test_sys_metric_aerr() {
runeq!(
con,
query!("sys", "metric"),
Element::RespCode(RespCode::ActionError)
);
runeq!(
con,
query!(
"sys",
"metric",
"this is cool",
"but why this extra argument?"
),
Element::RespCode(RespCode::ActionError)
)
}
#[dbtest]
async fn test_sys_metric_health() {
runeq!(
con,
query!("sys", "metric", "health"),
Element::String("good".to_owned())
)
}
}

@ -29,8 +29,8 @@ mod tests {
use skytable::{query, Element, Pipeline, RespCode};
async fn test_pipeline_heya_echo() {
let pipe = Pipeline::new()
.add(query!("heya", "first"))
.add(query!("heya", "second"));
.append(query!("heya", "first"))
.append(query!("heya", "second"));
let ret = con.run_pipeline(pipe).await.unwrap();
assert_eq!(
ret,
@ -41,7 +41,9 @@ mod tests {
)
}
async fn test_pipeline_basic() {
let pipe = Pipeline::new().add(query!("heya")).add(query!("get", "x"));
let pipe = Pipeline::new()
.append(query!("heya"))
.append(query!("get", "x"));
let ret = con.run_pipeline(pipe).await.unwrap();
assert_eq!(
ret,
@ -54,8 +56,8 @@ mod tests {
// although an error is simply just a response, but we'll still add a test for sanity
async fn test_pipeline_with_error() {
let pipe = Pipeline::new()
.add(query!("heya"))
.add(query!("get", "x", "y"));
.append(query!("heya"))
.append(query!("get", "x", "y"));
let ret = con.run_pipeline(pipe).await.unwrap();
assert_eq!(
ret,

@ -14,4 +14,4 @@ proc-macro = true
proc-macro2 = "1.0.36"
quote = "1.0.17"
rand = "0.8.5"
syn = { version = "1.0.89", features = ["full"] }
syn = { version = "1.0.90", features = ["full"] }

Loading…
Cancel
Save