mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 23:30:12 +01:00
improve integration test of cli scripts
This commit is contained in:
parent
4c73e260e3
commit
daef1c440b
9 changed files with 152 additions and 42 deletions
36
test/models/tracks_cli/tracks_api_test.rb
Normal file
36
test/models/tracks_cli/tracks_api_test.rb
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
require 'net/https'
|
||||
require './test/minimal_test_helper'
|
||||
require './doc/tracks_cli/tracks_api'
|
||||
|
||||
module TracksCli
|
||||
|
||||
class TracksApiTest < Test::Unit::TestCase
|
||||
|
||||
def test_https_detection
|
||||
uri = URI.parse("https://tracks.example.com")
|
||||
http = TracksCli::TracksAPI.new({}).get_http(uri)
|
||||
assert http.use_ssl?, "ssl expected"
|
||||
|
||||
uri = URI.parse("http://tracks.example.com")
|
||||
http = TracksCli::TracksAPI.new({}).get_http(uri)
|
||||
assert !http.use_ssl?, "no ssl expected"
|
||||
end
|
||||
|
||||
def test_context_uri
|
||||
uri = TracksCli::TracksAPI.new({context_prefix: "c"}).context_uri_for(16)
|
||||
assert_equal "c16.xml", uri.path
|
||||
|
||||
uri = TracksCli::TracksAPI.new({context_prefix: "c"}).context_uri_for(18)
|
||||
assert_equal "c18.xml", uri.path
|
||||
end
|
||||
|
||||
def test_static_uris_for_todo_and_project
|
||||
uri = TracksCli::TracksAPI.new({projects_uri: "https//tracks.example.com/projects.xml"}).project_uri
|
||||
assert_equal "https//tracks.example.com/projects.xml", uri.path
|
||||
|
||||
uri = TracksCli::TracksAPI.new({uri: "https//tracks.example.com/todos.xml"}).todo_uri
|
||||
assert_equal "https//tracks.example.com/todos.xml", uri.path
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
require './test/minimal_test_helper'
|
||||
require './doc/tracks_cli/tracks_xml_builder'
|
||||
require 'active_support/time_with_zone'
|
||||
|
||||
module TracksCli
|
||||
|
||||
class TimeToCompleteTest < Test::Unit::TestCase
|
||||
class TracksXmlBuilderTest < Test::Unit::TestCase
|
||||
def test_all
|
||||
todo = {
|
||||
description: "test action",
|
||||
|
|
@ -18,7 +19,7 @@ module TracksCli
|
|||
|
||||
xml = TracksCli::TracksXmlBuilder.new.build_todo_xml(todo)
|
||||
expect = "<todo><description>test action</description>" +
|
||||
"<project_id>1</project_id><show-from type=\"datetime\">2013-01-01T14:00:00Z</show-from>" +
|
||||
"<project_id>1</project_id><show-from type=\"datetime\">#{Time.at(todo[:show_from]).xmlschema}</show-from>" +
|
||||
"<notes>action notes</notes><tags><tag><name>one</name></tag><tag><name>two</name></tag></tags>" +
|
||||
"<context><name>@home</name></context><predecessor_dependencies><predecessor>123</predecessor></predecessor_dependencies></todo>"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue