Add integration test
wojtekmach opened this issue · comments
Something like this:
# test/integration_test.exs
@moduletag :integration
test "it works" do
credentials_path = System.get("GOOGLE_APPLICATION_CREDENTIALS", "credentials.json")
project_id = System.fetch!("PROJECT_ID")
credentials =
System.get("GOOGLE_APPLICATION_CREDENTIALS", "credentials.json")
|> File.read!()
|> Jason.decode!()
source = {:service_account, credentials, []}
{:ok, _} = Goth.start_link(name: MyGoth, source: source, http_client: &Req.request/1)
req =
Req.new()
|> ReqBigQuery.attach(project_id: project_id, dataset: "livebook", goth: MyGoth)
result = Req.post!(req, bigquery: "SELECT sepal_length, sepal_width FROM iris limit 2").body
assert result.num_rows == 2
assert result.columns == ["sepal_length", "sepal_width"]
assert [[x1, y1], [x2, y2]] = result.rows
assert is_float(x1)
assert is_float(y1)
assert is_float(x2)
assert is_float(x2)
end
by default, we wouldn't run tests tagged with integration, however we would have a mix test.all
alias to include those. See how Req does it.