Giter Site home page Giter Site logo

Comments (6)

stefanbirkner avatar stefanbirkner commented on June 12, 2024

Can you please show me such a test. I would like to understand better the problem that should be solved. You can remove details of the test and replace it with comments of course.

from fake-sftp-server-lambda.

Stromner avatar Stromner commented on June 12, 2024

Very short and without code it looks something like this:

// Setup
// Call to unrelated service
// Start fake-sftp-server
   // Call(s) to service that needs to use SFTP
   // Get file A from the server
      // Verify file
   // Get file B from the server
      // Verify file
   ...
   // If files passed verification upload response
      // Verify that service transformed the file correctly
...

I know there are a couple of things that I can do myself to make this big withSftpServer smaller. Like moving the last if block to a separate withSftpServer but it doesn't sit well with me to essentially use two ftp servers when in reality it's the same server. Or breaking out the verification but that breaks how we generally structure our tests in the code base with verifying as we go instead of doing it "in batches". But even if I did do these refactoring it would still be a a couple of rows wrapped inside the call to setup the fake ftp server thus the reason I would like to control the start and stop of the sftp server myself.

from fake-sftp-server-lambda.

Stromner avatar Stromner commented on June 12, 2024

Forgot to mention but it also creates a lot of extra bulk having to set up new users, ports and directories everywhere when generally it's the same for all tests

from fake-sftp-server-lambda.

stefanbirkner avatar stefanbirkner commented on June 12, 2024

Let me rephrase what I understood. From your point of view there are too issues with using Fake SFTP Server Lambda.

  1. Most of your test methods have an additional level of indent because the code is within a lambda expression like
@Test
void someTest() {
  withSftpServer(server -> {
     ... // a lot of lines with your test code
  });
}
  1. You have the same setup code in every method
@Test
void someTest() {
  //common setup code that is repeated in every test
  withSftpServer(server -> {
     ...
  });
}

Is that correct?

from fake-sftp-server-lambda.

Stromner avatar Stromner commented on June 12, 2024

Correct but as I added in the comment just above I also have to set up users, ports, folder et.c constantly even though they rarely differs between the tests that needs to use SFTP.

from fake-sftp-server-lambda.

mpindado avatar mpindado commented on June 12, 2024

+1 for this.

We use this library in scala and it makes our tests very big and less readable, we would like to have a single instance of the fake server for the whole tests in a file, like this:

val server = new FakeSftpServer()
override def beforeAllTests() {
  server.start
  server.putFile(.....)
  server.putFile(.....)
}

override def afterAllTests() {
  server.stop
}

The problem is that FakeSftpServer needs memory filesystem as constructor (have to add a dependency to marschall.memoryfilesystem) and server.start is private.

from fake-sftp-server-lambda.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.