From 5c15ec8f7b5fa3b03505d34f2edf6721c0b45666 Mon Sep 17 00:00:00 2001 From: Keiji Yoshimi Date: Sat, 4 Jun 2022 10:14:42 +0900 Subject: [PATCH] added test for LoginAck --- sqlx-core/src/mssql/protocol/login_ack.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sqlx-core/src/mssql/protocol/login_ack.rs b/sqlx-core/src/mssql/protocol/login_ack.rs index badc900463..7944474b46 100644 --- a/sqlx-core/src/mssql/protocol/login_ack.rs +++ b/sqlx-core/src/mssql/protocol/login_ack.rs @@ -4,6 +4,7 @@ use crate::error::Error; use crate::mssql::io::MssqlBufExt; use crate::mssql::protocol::pre_login::Version; +#[allow(dead_code)] #[derive(Debug)] pub(crate) struct LoginAck { pub(crate) interface: u8, @@ -37,3 +38,23 @@ impl LoginAck { }) } } + +#[test] +fn test_get() { + #[rustfmt::skip] + let mut buf = Bytes::from_static(&[ + 0x36, 0, 1, 0x74, 0, 0, 4, 0x16, 0x4d, 0, 0x69, 0, 0x63, 0, 0x72, 0, 0x6f, 0, 0x73, 0, 0x6f, 0, 0x66, 0, 0x74, 0, 0x20, 0, 0x53, 0, 51, 0, 0x4c, 0, 0x20, 0, 0x53, 0, 0x65, 0, 0x72, 0, 0x76, 0, 0x65, 0, 0x72, 0, 0, 0, 0, 0, 0xf, 0, 0x10, 0x7f, 0xe3, 0x13, 0, 4, 4, 0x34, 0, 0x30, 0, 0x39, 0, 0x36, 0, 4, 0x34, 0, 0x30, 0, 0x39, 0, 0x36, 0, 0xfd, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ]); + + let login_ack = LoginAck::get(&mut buf).unwrap(); + + assert_eq!(login_ack.interface, 1); + assert_eq!(login_ack.tds_version, 67108980); + + assert_eq!(login_ack.program_version.major, 15); + assert_eq!(login_ack.program_version.minor, 0); + assert_eq!(login_ack.program_version.build, 4223); + assert_eq!(login_ack.program_version.sub_build, 0); + + assert_eq!(login_ack.program_name, "Microsoft S3L Server\0\0"); +}