|
2 | 2 |
|
3 | 3 | use everruns_sdk::{ |
4 | 4 | CreateAgentRequest, CreateFileRequest, CreateSessionRequest, Everruns, InitialFile, |
5 | | - UpdateFileRequest, |
| 5 | + SetConnectionRequest, UpdateFileRequest, |
6 | 6 | }; |
7 | 7 | use wiremock::{ |
8 | 8 | Mock, MockServer, ResponseTemplate, |
@@ -547,3 +547,80 @@ async fn test_session_files_stat() { |
547 | 547 | assert_eq!(stat.size_bytes, 5); |
548 | 548 | assert!(!stat.is_directory); |
549 | 549 | } |
| 550 | + |
| 551 | +// --- Connections Tests --- |
| 552 | + |
| 553 | +#[tokio::test] |
| 554 | +async fn test_connections_set() { |
| 555 | + let server = MockServer::start().await; |
| 556 | + let client = Everruns::with_base_url("evr_test_key", &server.uri()).expect("client"); |
| 557 | + |
| 558 | + Mock::given(method("POST")) |
| 559 | + .and(path("/v1/user/connections/daytona")) |
| 560 | + .and(body_json(serde_json::json!({ |
| 561 | + "api_key": "dtn_secret_key" |
| 562 | + }))) |
| 563 | + .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({ |
| 564 | + "provider": "daytona", |
| 565 | + "created_at": "2026-03-31T00:00:00Z", |
| 566 | + "updated_at": "2026-03-31T00:00:00Z" |
| 567 | + }))) |
| 568 | + .mount(&server) |
| 569 | + .await; |
| 570 | + |
| 571 | + let conn = client |
| 572 | + .connections() |
| 573 | + .set("daytona", "dtn_secret_key") |
| 574 | + .await |
| 575 | + .expect("set connection should succeed"); |
| 576 | + |
| 577 | + assert_eq!(conn.provider, "daytona"); |
| 578 | +} |
| 579 | + |
| 580 | +#[tokio::test] |
| 581 | +async fn test_connections_list() { |
| 582 | + let server = MockServer::start().await; |
| 583 | + let client = Everruns::with_base_url("evr_test_key", &server.uri()).expect("client"); |
| 584 | + |
| 585 | + Mock::given(method("GET")) |
| 586 | + .and(path("/v1/user/connections")) |
| 587 | + .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({ |
| 588 | + "data": [{ |
| 589 | + "provider": "daytona", |
| 590 | + "created_at": "2026-03-31T00:00:00Z", |
| 591 | + "updated_at": "2026-03-31T00:00:00Z" |
| 592 | + }], |
| 593 | + "total": 1, |
| 594 | + "offset": 0, |
| 595 | + "limit": 100 |
| 596 | + }))) |
| 597 | + .mount(&server) |
| 598 | + .await; |
| 599 | + |
| 600 | + let connections = client |
| 601 | + .connections() |
| 602 | + .list() |
| 603 | + .await |
| 604 | + .expect("list connections should succeed"); |
| 605 | + |
| 606 | + assert_eq!(connections.data.len(), 1); |
| 607 | + assert_eq!(connections.data[0].provider, "daytona"); |
| 608 | +} |
| 609 | + |
| 610 | +#[tokio::test] |
| 611 | +async fn test_connections_remove() { |
| 612 | + let server = MockServer::start().await; |
| 613 | + let client = Everruns::with_base_url("evr_test_key", &server.uri()).expect("client"); |
| 614 | + |
| 615 | + Mock::given(method("DELETE")) |
| 616 | + .and(path("/v1/user/connections/daytona")) |
| 617 | + .respond_with(ResponseTemplate::new(204)) |
| 618 | + .mount(&server) |
| 619 | + .await; |
| 620 | + |
| 621 | + client |
| 622 | + .connections() |
| 623 | + .remove("daytona") |
| 624 | + .await |
| 625 | + .expect("remove connection should succeed"); |
| 626 | +} |
0 commit comments