Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added test for mssql protocol Info #1891

Merged
merged 1 commit into from
Jun 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions sqlx-core/src/mssql/protocol/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use bytes::{Buf, Bytes};
use crate::error::Error;
use crate::mssql::io::MssqlBufExt;

#[allow(dead_code)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for warnings reduction

sqlx-core/src/mssql/protocol/info.rs#L8
field is never read: `number`
sqlx-core/src/mssql/protocol/info.rs#L9
field is never read: `state`
sqlx-core/src/mssql/protocol/info.rs#L10
field is never read: `class`
sqlx-core/src/mssql/protocol/info.rs#L11
field is never read: `message`
sqlx-core/src/mssql/protocol/info.rs#L12
field is never read: `server`
sqlx-core/src/mssql/protocol/info.rs#L13
field is never read: `procedure`
sqlx-core/src/mssql/protocol/info.rs#L14
field is never read: `line`

#[derive(Debug)]
pub(crate) struct Info {
pub(crate) number: u32,
Expand Down Expand Up @@ -38,3 +39,21 @@ impl Info {
})
}
}

#[test]
fn test_get() {
#[rustfmt::skip]
let mut buf = Bytes::from_static(&[
0x74, 0, 0x47, 0x16, 0, 0, 1, 0, 0x27, 0, 0x43, 0, 0x68, 0, 0x61, 0, 0x6e, 0, 0x67, 0, 0x65, 0, 0x64, 0, 0x20, 0, 0x6c, 0, 0x61, 0, 0x6e, 0, 0x67, 0, 0x75, 0, 0x61, 0, 0x67, 0, 0x65, 0, 0x20, 0, 0x73, 0, 0x65, 0, 0x74, 0, 0x74, 0, 0x69, 0, 0x6e, 0, 0x67, 0, 0x20, 0, 0x74, 0, 0x6f, 0, 0x20, 0, 0x75, 0, 0x73, 0, 0x5f, 0, 0x65, 0, 0x6e, 0, 0x67, 0, 0x6c, 0, 0x69, 0, 0x73, 0, 0x68, 0, 0x2e, 0, 0xc, 0x61, 0, 0x62, 0, 0x64, 0, 0x30, 0, 0x62, 0, 0x36, 0, 0x37, 0, 0x62, 0, 0x64, 0, 0x34, 0, 0x39, 0, 0x33, 0, 0, 1, 0, 0, 0, 0xad, 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, 0x51, 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 info = Info::get(&mut buf).unwrap();

assert_eq!(info.number, 5703);
assert_eq!(info.state, 1);
assert_eq!(info.class, 0);
assert_eq!(info.message, "Changed language setting to us_english.");
assert_eq!(info.server, "abd0b67bd493");
assert_eq!(info.procedure, "");
assert_eq!(info.line, 1);
}