How does a POST request to a staging site work?

Published

I’m working on an app written in Ruby on Rails with GraphQL API. In my test file, I sent a POST request to our staging site in order to execute a sign in mutation. This is the test file:

require 'test_helper'

class Mutations::SignInUserTest < ActionDispatch::IntegrationTest
    def perform(args = {})
        Mutations::SignInUser.new(object: nil, field: nil, context: {}).resolve(args)
    end

    test 'sign in user' do
        post "apistaging.app.com/graphql"

        user = perform(
            auth: {
                user_id: "example",
                password: "example"
            }
        )

        assert user.persisted?
    end
end

However, in test.log, this is what I see when I run rails test

Started POST "/graphql" for 127.0.0.1 at 2021-06-16 00:06:27 +0700
Processing by GraphqlController#execute as HTML
Completed 200 OK in 32ms (Views: 0.3ms | ActiveRecord: 0.0ms)

Note that I have a Dockerfile and a docker-compose.yml in my root directory, ran docker-compose up then docker exec into the container of our app to run rails test. Does the log mean that the POST request is being sent to my localhost:3000/graphql? I’m asking because the staging database should have user data for signing in, but for some reason the database is empty when I run the tests, so all the queries and mutations return null.
I also have a .sql file in my root directory, is there a way to import the data in the file into my database so I can test it?

Source: Docker Questions

Published
Categorised as docker, graphql, ruby-on-rails, unit-testing Tagged , , ,

Answers

Leave a Reply

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq