fn test_set_connector_details_user()

in azure-kusto-data/src/client_details.rs [196:256]


    fn test_set_connector_details_user() {
        let details = ConnectorDetailsBuilder::default()
            .with_name("MyConnector")
            .with_version("1.0")
            .with_send_user(true)
            .with_override_user("user1")
            .with_app_name("MyApp")
            .with_app_version("1.0.1")
            .with_additional_fields(vec![("key1", "value1"), ("key2", "value2")])
            .build()
            .unwrap();

        let (header, user) = set_connector_details(details);

        let expected_header =
            "Kusto.MyConnector:{1.0}|App.{MyApp}:{1.0.1}|key1:{value1}|key2:{value2}".to_string();

        assert_eq!(header, expected_header);

        assert_eq!(user, "user1");

        let details = ConnectorDetailsBuilder::default()
            .with_name("MyConnector")
            .with_version("1.0")
            .with_send_user(false)
            .with_app_name("MyApp")
            .with_app_version("1.0.1")
            .with_additional_fields(vec![("key1", "value1"), ("key2", "value2")])
            .build()
            .unwrap();

        let (header, user) = set_connector_details(details);

        let expected_header =
            "Kusto.MyConnector:{1.0}|App.{MyApp}:{1.0.1}|key1:{value1}|key2:{value2}".to_string();

        assert_eq!(header, expected_header);

        assert_eq!(user, "[none]");

        let details = ConnectorDetailsBuilder::default()
            .with_name("MyConnector")
            .with_version("1.0")
            .with_send_user(true)
            .with_app_name("MyApp")
            .with_app_version("1.0.1")
            .with_additional_fields(vec![("key1", "value1"), ("key2", "value2")])
            .build()
            .unwrap();

        let (header, user) = set_connector_details(details);

        let expected_header =
            "Kusto.MyConnector:{1.0}|App.{MyApp}:{1.0.1}|key1:{value1}|key2:{value2}".to_string();

        // We don't know the actual user that will be returned, but we can at least check
        // that it's not an empty string.
        assert_ne!(user, "", "user should not be an empty string, but it is");

        assert_eq!(header, expected_header);
    }