Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyabee committed Aug 29, 2016
1 parent 9388dd7 commit f3729b1
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ CloudVision.analyze("/Users/yourname/Images/cat.jpg", features: [:image_properti
CloudVision.analyze("cat.jpg", from: :storage, features: [:image_properties])
```

### Available features(you can pass as many as you want(`features: [...]`)):
### Available features (you can pass as many as you want(`features: [...]`)):
```elixir
[:label, :logo, :text, :face, :landmark, :safe_search, :image_properties]
# and the default
Expand Down
7 changes: 6 additions & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ use Mix.Config
# Configuration from the imported file will override the ones defined
# here (which is why it is important to import them last).
#
# import_config "#{Mix.env}.exs"


config :goth, json: "config/dummy_creds.json" |> Path.expand |> File.read!
config :cloud_vision, gcsUri: "dummy.appspot.com"

import_config "#{Mix.env}.exs"
1 change: 1 addition & 0 deletions config/dev.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use Mix.Config
12 changes: 12 additions & 0 deletions config/dummy_creds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"type": "service_account",
"project_id": "dummy_project_id",
"private_key_id": "dummy_key_id",
"private_key": "-----BEGIN PRIVATE KEY-----\ndummy_private_key\n-----END PRIVATE KEY-----\n",
"client_email": "dummy_email@dummy_project_id.iam.gserviceaccount.com",
"client_id": "dummy_client_id",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/google-cloud-storage%40dummy_project_id.iam.gserviceaccount.com"
}
1 change: 1 addition & 0 deletions config/test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use Mix.Config
8 changes: 7 additions & 1 deletion lib/cloud_vision.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ defmodule CloudVision do
end
end

defp build_params(img_path, opts), do:
@doc """
iex> CloudVision.build_params("cat.jpg", from: :storage, features: [:image_properties])
%{requests: [%{features: [%{type: "IMAGE_PROPERTIES"}],
image: %{source: %{gcsImageUri: "gs://dummy.appspot.com/cat.jpg"}}}]}
"""

def build_params(img_path, opts), do:
%{requests: [%{image: build_image(img_path, opts[:from]), features: build_features(opts[:features])}]}

defp build_image(img_path, nil), do: build_image(img_path, :local)
Expand Down
4 changes: 0 additions & 4 deletions test/cloud_vision_test.exs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
defmodule CloudVisionTest do
use ExUnit.Case
doctest CloudVision

test "the truth" do
assert 1 + 1 == 2
end
end

0 comments on commit f3729b1

Please sign in to comment.