Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Chung
    @chungwong

    I created the following under Drogon root dir with some dummy tests.

    tests
    ├── CMakeLists.txt
    └── main.cc

    when I did

    cd build
    cmake ..
    make && make test

    everything worked. However, when I tried to add drogon into CTest.
    file: test/CMakeLists.txt

    add_executable(main main.cc)
    add_test(main main)
    
    # FIXME
    # include(ParseAndAddDrogonTest)
    # add_executable(main main.cc)
    # target_link_libraries(main PRIVATE drogon)
    # ParseAndAddDrogonTest(main)

    It threw an error at me

    CMake Error at tests/CMakeLists.txt:5 (include):
      include could not find load file:
    
        ParseAndAddDrogonTest
    Chung
    @chungwong
    and I cannot find a reference to ParseAndAddDrogonTest in the whole source code.
    Did I get the idea wrong?
    João Fernandes
    @0rangeFox
    @chungwong Hey, I didn't understand, so, you mean, add framework "Drogon" to your project?
    Chung
    @chungwong
    @0rangeFox not really, I mean adding unit test to my drogon project
    which is integrating the testing framework of Drogon into CTest
    João Fernandes
    @0rangeFox
    Just curiosity, don't take it in bad way, mind I ask why you want it for?
    Chung
    @chungwong
    My hobby project at this moment doesn't have any unit testing. So it would be great if I can test the URLs I have made
    João Fernandes
    @0rangeFox
    Ah sure, I can recommend you the Postman application for it.
    Chung
    @chungwong
    but I guess it is not really testing? In that case I can use cURL to do that too?
    João Fernandes
    @0rangeFox
    Well, I use debugger from IDE and Postman to call it for check if everything is fine. But of course, you can use cURL for it.
    Chung
    @chungwong
    it would be great if we can just run make test to run all unit tests.
    I am just not familiar with how I should integrate drogon test to CTest
    Martin Chang
    @marty1885
    Hi @chungwong. That is a quark of CMake. There's no formal way to distribute cmake modules. The best we could do is to distribute it with the source and install is somewhere on your system.
    Either copy the file into your project and point CMAKE_MODULE_PATH to the containing folder. Or add this line somewhere before the include set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH} /usr/lib/cmake/Drogon")(if you are on UNIX and installed drogon to /usr.
    In short:
    Chung
    @chungwong
    aha, no wonder I couldn't find any reference to ParseAndAddDrogonTest in the source. It is actually ParseAndAddDrogonTests
    Martin Chang
    @marty1885
    mkdir cmake
    wget "https://github.com/an-tao/drogon/blob/d888816997969435b907bec3881df7f4229f3583/cmake/ParseAndAddDrogonTests.cmake" -O cmake/ParseAndAddDrogonTests.cmake
    Then add set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake") somewhere at the beginning of your CMake script.
    Ah yes. I should fix that typo :P
    Chung
    @chungwong
    Thanks Martin. Let me try it out
    wait a second. I just realised I copied a template/file from Drogon's source code into my project, and then make some changes to my CMakeLists.txt. Isn't it the job of the generator Drogon has been using for generating the project template drogon_ctl create project your_project_name
    Martin Chang
    @marty1885
    You can customize the template as much as you wish.
    And we don't want to force users to use our own testing framework. Choosing testing frameworks is a touchy subject.
    Chung
    @chungwong
    of course not. However, what about
    drogon_ctl create project your_project_name --include_drogon_test
    Martin Chang
    @marty1885
    Good idea! You should open an issue and we could discuss in detail there
    Chung
    @chungwong
    Alababdiy
    @Alababdiy
    image.png
    My application not load controller
    image.png
    image.png
    image.png
    The messenger_receiver controller not registered on app when i request /view got 404 not found
    João Fernandes
    @0rangeFox
    Hey @Alababdiy, are you loading these controllers on CMakeLists?
    Aayush-2492
    @Aayush-2492
    does newHttpViewResponse() take only the name of .csp file or is .html also fine?
    An Tao
    @an-tao
    must be .csp, but it's content can be anything including HTML docs
    Martin Chang
    @marty1885
    There's also CSP syntax highlighting support for VSCode: https://marketplace.visualstudio.com/items?itemName=marty1885.drogon-csp-lanuage
    Aayush-2492
    @Aayush-2492
    Thanks for the extension. didn't know about it
    Rafael Bugajewski
    @rbugajewski
    yeah, thanks, I also didn’t know about it
    Rafael Bugajewski
    @rbugajewski
    @Aayush-2492 I’m throwing Ember.js into the mix :) https://emberjs.com/
    Aayush-2492
    @Aayush-2492
    @rbugajewski thanks but already started with vue :)
    Rafael Bugajewski
    @rbugajewski
    Good luck! Vue is probably the better choice in the generic case :)
    @0rangeFox What you talked about is a Smoke Test, but what @chungwong wants are Unit Tests. Both are tests, yes, but slightly different ones. They complement each other.
    1 reply
    Alababdiy
    @Alababdiy
    Hi .. i'm newbie
    after i add :-
    auto db2 = app().getFastDbClient();
    get this error
    Assertion failed: (iter != dbFastClientsMap_.end()), function getFastDbClient, file /Users/abdo/Workshop/vcpkg/buildtrees/drogon/src/v1.7.1-c852679de5.clean/lib/src/DbClientManager.h, line 42.
    config.json:-
    "db_clients": [
    {
    //name: Name of the client,'default' by default
    "name":"default",
    //rdbms: Server type, postgresql,mysql or sqlite3, "postgresql" by default
    "rdbms": "postgresql",
    //filename: Sqlite3 db file name
    //"filename":"",
    //host: Server address,localhost by default
    "host": "ec2-52-212-157-46.eu-west-1.compute.amazonaws.com",
    //port: Server port, 5432 by default
    "port": 5432,
    //dbname: Database name
    "dbname": "XXXXXX",
    //user: 'postgres' by default
    "user": "XXXXXX",
    //passwd: '' by default
    "passwd": "XXXXXX",
    //is_fast: false by default, if it is true, the client is faster but user can't call
    //any synchronous interface of it.
    "is_fast": true,
    //client_encoding: The character set used by the client. it is empty string by default which
    //means use the default character set.
    //"client_encoding": "",
    //number_of_connections: 1 by default, if the 'is_fast' is true, the number is the number of
    //connections per IO thread, otherwise it is the total number of all connections.
    "number_of_connections": 5,
    //timeout: -1.0 by default, in seconds, the timeout for executing a SQL query.
    //zero or negative value means no timeout.
    "timeout": 5
    }
    ....
    João Fernandes
    @0rangeFox
    Hey guys, could someone tell me if this is the only way to do it or is there a better way?
    image.png
    By the way, the variable "_dbClient" is of type: IOThreadStorage<DbClientPtr>
    João Fernandes
    @0rangeFox
    I think I was not very specific to my issue, what I really wanted to know, is regarding the variable "_dbClient", when passing in the "Captures" of the lambdas expressions.
    Rafael Bugajewski
    @rbugajewski
    It’s really hard to say something, because the context is missing.
    João Fernandes
    @0rangeFox
    Yes I get it but I personally also read that and got confused and I can't simplify it any more than that, what I basically meant, if you look there is a "capture" with the following parameter, "_dbClient = *_dbClient" in the last lambda, and I wonder if there is any way to just send "_dbClient" as the first lambda?
    praveenpillay
    @praveenpillay
    For a front end desktop application heavy on real time chart updates from drogon server, what would you guys recommend? Flutter, React Native, Vue or something else? Thank you!
    1 reply
    An Tao
    @an-tao

    Yes I get it but I personally also read that and got confused and I can't simplify it any more than that, what I basically meant, if you look there is a "capture" with the following parameter, "_dbClient = *_dbClient" in the last lambda, and I wonder if there is any way to just send "_dbClient" as the first lambda?

    Why not just capture this pointer instead of _dbClient

    João Fernandes
    @0rangeFox
    Because I need to fetch the object that is inside of the IOThreadStorage. Or am I forgetting something?