MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / test_application

Function test_application

chirpstack/src/api/application.rs:1903–2031  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1901
1902 #[tokio::test]
1903 async fn test_application() {
1904 let _guard = test::prepare().await;
1905
1906 // setup admin user
1907 let u = user::User {
1908 is_admin: true,
1909 is_active: true,
1910 email: "admin@admin".into(),
1911 email_verified: true,
1912 ..Default::default()
1913 };
1914 let u = user::create(u).await.unwrap();
1915
1916 // create tenant
1917 let t = tenant::create(tenant::Tenant {
1918 name: "test-tenant".into(),
1919 can_have_gateways: true,
1920 max_gateway_count: 10,
1921 ..Default::default()
1922 })
1923 .await
1924 .unwrap();
1925
1926 // setup api
1927 let service = Application::new(RequestValidator::new());
1928
1929 // create
1930 let create_req = api::CreateApplicationRequest {
1931 application: Some(api::Application {
1932 tenant_id: t.id.to_string(),
1933 name: "test-app".into(),
1934 ..Default::default()
1935 }),
1936 };
1937 let mut create_req = Request::new(create_req);
1938 create_req
1939 .extensions_mut()
1940 .insert(AuthID::User(Into::<uuid::Uuid>::into(u.id)));
1941 let create_resp = service.create(create_req).await.unwrap();
1942 let create_resp = create_resp.get_ref();
1943
1944 //get
1945 let get_req = api::GetApplicationRequest {
1946 id: create_resp.id.clone(),
1947 };
1948 let mut get_req = Request::new(get_req);
1949 get_req
1950 .extensions_mut()
1951 .insert(AuthID::User(Into::<uuid::Uuid>::into(u.id)));
1952 let get_resp = service.get(get_req).await.unwrap();
1953 assert_eq!(
1954 Some(api::Application {
1955 id: create_resp.id.clone(),
1956 tenant_id: t.id.to_string(),
1957 name: "test-app".into(),
1958 ..Default::default()
1959 }),
1960 get_resp.get_ref().application

Callers

nothing calls this directly

Calls 12

prepareFunction · 0.85
unwrapMethod · 0.80
to_stringMethod · 0.80
insertMethod · 0.80
UserClass · 0.70
createFunction · 0.50
intoMethod · 0.45
createMethod · 0.45
getMethod · 0.45
updateMethod · 0.45
listMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected