I'm utilizing Google's API in my own project. I figure it'll make my own code more readable by wrapping some API functions in one-line wrappers. But I am not sure to which extent should I write tests for this wrappers.
On one hand, I understand that I can't control how Google API changes/hehaves in the future. On the other hand, since all I do is wrap the API functions, testing those wrappers basically aligns with testing the API function calls that are wrapped, which have been done when Google ship them. Then I find myself writing some tests just to confirm the returns from the wrappers have the right class. I think I must have done something wrong here.
So my question is, is it necessary to test those wrappers? If so, to what extent? If not, why?
These are the wrappers:
#api_wrapper.rb
def get_client_id_from(credentials_path)
Google::Auth::ClientId.from_file(credentials_path)
end
def create_token_store_with_path(token_store_path)
Google::Auth::Stores::FileTokenStore.new(file: token_store_path)
end
def create_authorizer_with_client_id_and_token_within_scope(client_id, token_store, scope)
#the order of google's arguments doesn't sound right
Google::Auth::UserAuthorizer.new(client_id, scope, token_store)
end
These are the tests for wrappers:
# test.rb
test "should generate a token store" do
test_token = create_token_store_with_path(@token_path)
assert_instance_of(Google::Auth::Stores::FileTokenStore, test_token)
end
Aucun commentaire:
Enregistrer un commentaire