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

feat: add agent tests #19

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

feat: add agent tests #19

wants to merge 9 commits into from

Conversation

WoodenMaiden
Copy link
Contributor

No description provided.

@WoodenMaiden WoodenMaiden marked this pull request as ready for review November 27, 2023 23:24

pub async fn register(&mut self, port: u16) -> Result<String> {
#[tonic::async_trait]
Copy link
Contributor

Choose a reason for hiding this comment

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

I would have used tokio async_trait here


assert_eq!(code_return.stdout, "This is stdout");
assert_eq!(code_return.stderr, "This is stderr");
assert_eq!(code_return.exit_code, 1);
}

/// Test the creation of a file
Copy link
Contributor

Choose a reason for hiding this comment

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

Is that really what it is testing?


string
#[test]
fn run_one_works_with_ouputs_and_code() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Personally I tend to prefix all test function's names with 'test_' to easily differentiate it from other functions and to make sure that I specify in the name what it is supposed to test


assert_eq!(code_return.stdout, "This is stdout");
assert_eq!(code_return.stderr, "This is stderr");
assert_eq!(code_return.exit_code, 1);
}

/// Test the creation of a file
#[test]
fn workload_runs_correctly() {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is a workload supposed to be?

@@ -15,6 +15,10 @@ const fn default_local_port() -> u16 {
0
}

fn default_workspace_path() -> String {
std::env::temp_dir().to_str().unwrap().to_string()
Copy link
Contributor

Choose a reason for hiding this comment

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

.to_str().unwrap().to_string() seems a bit ugly :/

pub id: String,
}

impl LambdoAgentServer {
pub async fn new(config: AgentConfig) -> Self {
pub async fn new<C: ClientTrait + SelfCreatingClientTrait + 'static>(
Copy link
Contributor

Choose a reason for hiding this comment

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

I really don't like the idea of a SelfCreatingClientTrait.
For me, we should do that a bit differently:

  • LambdoAgentServer::new() should take a ClientTrait as a parameter
  • ClientTrait should have a config() function that would be called in LambdoAgentServer::new()

That would probably reduce the complexity by a lot IMO

agent/lib/src/api/server.rs Show resolved Hide resolved
@WoodenMaiden WoodenMaiden self-assigned this Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants