Skip to content

Commit

Permalink
Rename files
Browse files Browse the repository at this point in the history
Adding files for tests
  • Loading branch information
Acollie committed Jun 6, 2023
1 parent 26433fd commit 4eedb7b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
mod file_handeling;
mod upload_handeling;
mod file_handling;
mod upload_handling;
mod handle_role;
mod lambda_handeling;
mod lambda_handling;

use aws_sdk_lambda as lambda;
use crate::file_handeling::{FileType, post_deployment_cleanup};
use crate::upload_handeling::{lambda_upload};
use crate::file_handling::{FileType, post_deployment_cleanup};
use crate::upload_handling::{lambda_upload};

fn resolve_runtime(file_type: FileType) -> lambda::types::Runtime {
match file_type {
Expand All @@ -24,16 +24,16 @@ async fn main()-> Result<(), Box<dyn std::error::Error>>{
let client = lambda::Client::new(&config);



let filename = &args[1];
let function_name = &args[2];
let service_role = &args[3];
let file_type = file_handeling::file_detection(filename);
let functions_names = lambda_handeling::get_lambda_names(&client).await;
let file_type = file_handling::file_detection(filename);
let functions_names = lambda_handling::get_lambda_names(&client).await;

lambda_upload(&functions_names, service_role, &client, filename, file_type, function_name).await.expect("TODO: panic message");

post_deployment_cleanup(file_type).unwrap();

Ok(())
}

10 changes: 5 additions & 5 deletions src/upload_handeling.rs → src/upload_handling.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
use std::collections::HashSet;
use std::fs::read;
use aws_sdk_lambda::types::{FunctionCode};
use crate::file_handeling::{convert_contents_to_blob, FileType};
use crate::file_handling::{convert_contents_to_blob, FileType};
use aws_sdk_lambda as lambda;
use aws_sdk_lambda::Client;
use crate::{file_handeling, resolve_runtime};
use crate::{file_handling, resolve_runtime};

pub async fn lambda_upload(lambda_functions:&HashSet<String>,service_role:&str,client:&Client,filename:&str,file_type:FileType,function_name:&str)->Result<(),()>{
file_handeling::zip_file(filename,file_type).unwrap();
file_handling::zip_file(filename, file_type).unwrap();
let file_contents = read("deployment.zip").unwrap();
let blob = lambda::primitives::Blob::new(file_contents);
let function_code = FunctionCode::builder()
.zip_file(blob)
.build();

file_handeling::zip_file(filename,file_type).unwrap();
file_handling::zip_file(filename, file_type).unwrap();
let file_without_extension = filename.split(".").next().unwrap();


Expand All @@ -39,7 +39,7 @@ pub async fn lambda_upload(lambda_functions:&HashSet<String>,service_role:&str,c
Ok(())
}

#[cfg(test)]
#[tokio::test]
async fn test_lambda_upload(){
let mut lambda_functions = HashSet::new();
lambda_functions.insert("test".to_string());
Expand Down
7 changes: 7 additions & 0 deletions test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "fmt"

func main() {
fmt.Println("Hello, World!")
}
3 changes: 3 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

def handler(res,req):
return "Example lambda function"

0 comments on commit 4eedb7b

Please sign in to comment.