require 'test_helper'

class Api::BuildsControllerTest < ActionController::TestCase
  def setup
    @controller = Api::BuildsController.new
  end

  def params
    {"language"=>"elixir", "git_repo_url"=>"git://github.com/rrrene/inch_ex.git", "travis" => true, "travis_repo_slug" => "rrrene/inch_ex", "args"=>nil, "objects"=>[{"object_type"=>"ModuleObject", "id"=>"InchEx", "module"=>"Elixir.InchEx", "moduledoc"=>nil, "source"=>nil, "type"=>nil, "typespecs"=>nil}, {"object_type"=>"ModuleObject", "id"=>"InchEx.Config", "module"=>"Elixir.InchEx.Config", "moduledoc"=>nil, "source"=>nil, "type"=>nil, "typespecs"=>nil}, {"object_type"=>"ModuleObject", "id"=>"InchEx.Docs.Formatter", "module"=>"Elixir.InchEx.Docs.Formatter", "moduledoc"=>"Provide JSON-formatted documentation\n", "source"=>nil, "type"=>nil, "typespecs"=>nil}, {"object_type"=>"ModuleObject", "id"=>"InchEx.Docs.Retriever", "module"=>"Elixir.InchEx.Docs.Retriever", "moduledoc"=>"Functions to extract documentation information from modules.\n", "source"=>nil, "type"=>nil, "typespecs"=>nil}, {"object_type"=>"ModuleObject", "id"=>"InchEx.Docs.Retriever.Error", "module"=>"Elixir.InchEx.Docs.Retriever.Error", "moduledoc"=>nil, "source"=>nil, "type"=>"exception", "typespecs"=>nil}, {"object_type"=>"ModuleObject", "id"=>"InchEx.FunctionObject", "module"=>"Elixir.InchEx.FunctionObject", "moduledoc"=>nil, "source"=>nil, "type"=>nil, "typespecs"=>nil}, {"object_type"=>"ModuleObject", "id"=>"InchEx.ModuleObject", "module"=>"Elixir.InchEx.ModuleObject", "moduledoc"=>nil, "source"=>nil, "type"=>nil, "typespecs"=>nil}, {"object_type"=>"ModuleObject", "id"=>"InchEx.Reporter.Local", "module"=>"Elixir.InchEx.Reporter.Local", "moduledoc"=>nil, "source"=>nil, "type"=>nil, "typespecs"=>nil}, {"object_type"=>"ModuleObject", "id"=>"InchEx.Reporter.Remote", "module"=>"Elixir.InchEx.Reporter.Remote", "moduledoc"=>nil, "source"=>nil, "type"=>nil, "typespecs"=>nil}, {"object_type"=>"ModuleObject", "id"=>"InchEx.TypeObject", "module"=>"Elixir.InchEx.TypeObject", "moduledoc"=>nil, "source"=>nil, "type"=>nil, "typespecs"=>nil}, {"object_type"=>"ModuleObject", "id"=>"Mix.Tasks.Inch", "module"=>"Elixir.Mix.Tasks.Inch", "moduledoc"=>nil, "source"=>nil, "type"=>nil, "typespecs"=>nil}, {"object_type"=>"ModuleObject", "id"=>"Mix.Tasks.Inch.Report", "module"=>"Elixir.Mix.Tasks.Inch.Report", "moduledoc"=>nil, "source"=>nil, "type"=>nil, "typespecs"=>nil}, {"object_type"=>"FunctionObject", "module_id"=>"InchEx", "arity"=>4, "doc"=>false, "id"=>"generate_docs/4", "name"=>"generate_docs", "signature"=>[["project", [], nil], ["version", [], nil], ["args", [], nil], ["options", [], nil]], "source"=>nil, "specs"=>nil, "type"=>"def"}, {"object_type"=>"FunctionObject", "module_id"=>"InchEx.Docs.Formatter", "arity"=>3, "doc"=>"Generate JSON documentation for the given modules\n", "id"=>"run/3", "name"=>"run", "signature"=>[["modules", [], nil], ["args", [], nil], ["config", [], nil]], "source"=>nil, "specs"=>nil, "type"=>"def"}, {"object_type"=>"FunctionObject", "module_id"=>"InchEx.Docs.Retriever", "arity"=>2, "doc"=>"Extract documentation from all modules in the specified directory\n", "id"=>"docs_from_dir/2", "name"=>"docs_from_dir", "signature"=>[["dir", [], nil], ["config", [], nil]], "source"=>nil, "specs"=>nil, "type"=>"def"}, {"object_type"=>"FunctionObject", "module_id"=>"InchEx.Docs.Retriever", "arity"=>2, "doc"=>"Extract documentation from all modules in the specified list of files\n", "id"=>"docs_from_files/2", "name"=>"docs_from_files", "signature"=>[["files", [], nil], ["config", [], nil]], "source"=>nil, "specs"=>nil, "type"=>"def"}, {"object_type"=>"FunctionObject", "module_id"=>"InchEx.Docs.Retriever", "arity"=>2, "doc"=>"Extract documentation from all modules in the list `modules`\n", "id"=>"docs_from_modules/2", "name"=>"docs_from_modules", "signature"=>[["modules", [], nil], ["config", [], nil]], "source"=>nil, "specs"=>nil, "type"=>"def"}, {"object_type"=>"FunctionObject", "module_id"=>"InchEx.Docs.Retriever.Error", "arity"=>1, "doc"=>"Callback implementation of `Exception.exception/1`.", "id"=>"exception/1", "name"=>"exception", "signature"=>[["args", [], nil]], "source"=>nil, "specs"=>[["::", {"line"=>19}, [["exception", {"line"=>19}, [[[".", {"line"=>19}, ["Elixir.Keyword", "t"]], {"line"=>19}, []]]], [[".", {"line"=>19}, ["Elixir.Exception", "t"]], {"line"=>19}, []]]]], "type"=>"def"}, {"object_type"=>"FunctionObject", "module_id"=>"InchEx.Docs.Retriever.Error", "arity"=>1, "doc"=>"Callback implementation of `Exception.message/1`.", "id"=>"message/1", "name"=>"message", "signature"=>[["exception", [], nil]], "source"=>nil, "specs"=>[["::", {"line"=>19}, [["message", {"line"=>19}, [[[".", {"line"=>19}, ["Elixir.Exception", "t"]], {"line"=>19}, []]]], [[".", {"line"=>19}, ["Elixir.String", "t"]], {"line"=>19}, []]]]], "type"=>"def"}, {"object_type"=>"FunctionObject", "module_id"=>"InchEx.Reporter.Local", "arity"=>2, "doc"=>"  Runs inch locally, if installed. If you want to force usage of a particular\n  inch installation, set INCH_PATH environment variable:\n\n    export INCH_PATH=/home/rrrene/projects/inch\n\n  Otherwise, InchEx will take whatever `inch` command it finds. If it does\n  not find any, it sends the data to the open API at inch-ci.org (or the\n  endpoint defined in the INCH_CLI_API environment variable) to perform\n  the analysis and reports the findings back.\n", "id"=>"run/2", "name"=>"run", "signature"=>[["filename", [], nil], ["\\\\", [], [["args", [], nil], []]]], "source"=>nil, "specs"=>nil, "type"=>"def"}, {"object_type"=>"FunctionObject", "module_id"=>"InchEx.Reporter.Remote", "arity"=>2, "doc"=>"  Runs inch remotely, if already invented.\n", "id"=>"run/2", "name"=>"run", "signature"=>[["filename", [], nil], ["", [], "Elixir"]], "source"=>nil, "specs"=>nil, "type"=>"def"}, {"object_type"=>"FunctionObject", "module_id"=>"Mix.Tasks.Inch", "arity"=>4, "doc"=>false, "id"=>"run/4", "name"=>"run", "signature"=>[["args", [], nil], ["\\\\", [], [["config", [], nil], [[".", {"line"=>10}, ["Elixir.Mix.Project", "config"]], {"line"=>10}, []]]], ["\\\\", [], [["generator", [], nil], [[".", [], ["erlang", "make_fun"]], {"line"=>10}, ["Elixir.InchEx", "generate_docs", 4]]]], ["\\\\", [], [["reporter", [], nil], "Elixir.InchEx.Reporter.Local"]]], "source"=>nil, "specs"=>nil, "type"=>"def"}, {"object_type"=>"FunctionObject", "module_id"=>"Mix.Tasks.Inch.Report", "arity"=>4, "doc"=>false, "id"=>"run/4", "name"=>"run", "signature"=>[["", [], "Elixir"], ["\\\\", [], [["config", [], nil], [[".", {"line"=>8}, ["Elixir.Mix.Project", "config"]], {"line"=>8}, []]]], ["\\\\", [], [["generator", [], nil], [[".", [], ["erlang", "make_fun"]], {"line"=>8}, ["Elixir.InchEx", "generate_docs", 4]]]], ["\\\\", [], [["reporter", [], nil], "Elixir.InchEx.Reporter.Remote"]]], "source"=>nil, "specs"=>nil, "type"=>"def"}], "controller"=>"api/builds", "action"=>"run", "build"=>{}}
  end

  test "should not error on GET" do
    get :run
    assert_response :success
  end

  test "should run with valid params" do
    post :run, params
    assert_response :success
  end
end
