Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

339 jira tests #358

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions test/fake_jira.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Copyright (c) 2016-2022 Yegor Bugayenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the 'Software'), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

class FakeJira
attr_reader :name, :repo

def initialize(options = {})
@name = 'JIRA'
@repositories = options[:repositories] || []
@repo = options[:repo]
end

def repositories(user = nil, _options = {})
@repositories unless user
end

def issue(_)
{
state: 'open',
author: {
id: '1',
username: 'yegor256'
},
milestone: {
number: 1,
title: 'v0.1'
}
}
end

def close_issue(_); end

def create_issue(_)
{
number: 1,
html_url: 'url'
}
end

def update_issue(_, _); end

def labels
[
{
id: ``,
name: 'Dev',
color: '#ff00ff'
}
]
end

def add_label(_, _); end

def add_labels_to_an_issue(_, _); end

def add_comment(_, _); end

def create_commit_comment(_, _)
{
html_url: 'url'
}
end

def list_commits
[
{
sha: '123456',
html_url: 'url'
}
]
end

def user(_)
{
name: 'yegor256',
email: '[email protected]'
}
end

def star; end

def repository(_ = nil)
{
private: false
}
rescue JIRA::Error::NotFound => e
raise "Repository #{name} is not available: #{e.message}"
end

private

def git_repo
# Output:
# repo -> GitRepo
raise NotImplementedError, 'You must implement this method'
end
end
36 changes: 36 additions & 0 deletions test/test_jira.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright (c) 2016-2022 Yegor Bugayenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the 'Software'), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

require 'test/unit'
require_relative 'test__helper'
require_relative '../objects/clients/jira'

# Jira test.
# Author:: Yegor Bugayenko ([email protected])
# Copyright:: Copyright (c) 2016-2022 Yegor Bugayenko
# License:: MIT
class TestGitlab < Test::Unit::TestCase
def test_configuration_right
jira = JiraClient.new.client
assert_raises JIRA::Error::MissingCredentials do
jira.user('0pdd')['username']
end
end
end