Skip to content

Commit 55dc4f6

Browse files
committed
TRS tweaks tests for Git-versioned workflows.
Possibly fixes #614 by using version name for TRS Tool Version name, which will the same as the git branch/tag name if imported from git repo
1 parent c43adc7 commit 55dc4f6

File tree

9 files changed

+74
-5
lines changed

9 files changed

+74
-5
lines changed

app/controllers/workflows_controller.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ def create_from_git
134134
end
135135
end
136136

137-
138137
#
139138
# # Displays the form Wizard for providing the metadata for the workflow
140139
# def provide_metadata

app/models/ga4gh/trs/v2/tool.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def organization
2323
end
2424

2525
def versions
26-
super.map { |v| ToolVersion.new(self, v) }
26+
all_versions.map { |v| ToolVersion.new(self, v) }
2727
end
2828

2929
def toolclass

app/models/ga4gh/trs/v2/tool_version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def tool_id
2626
end
2727

2828
def name
29-
title
29+
@workflow_version.is_a?(GitVersion) ? @workflow_version.name : title
3030
end
3131

3232
def authors

lib/seek/git/versioning_compatibility.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ def find_version(version)
1515
end
1616

1717
def describe_version(version_number)
18-
vs = is_git_versioned? ? git_versions : versions
18+
vs = all_versions
1919

2020
return '(earliest)' if version_number == vs.first.version
2121
return '(latest)' if version_number == vs.last.version
2222
''
2323
end
24+
25+
def all_versions
26+
is_git_versioned? ? git_versions : versions
27+
end
2428
end
2529
end
2630
end

test/factories/git.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
f.name 'version 1.0.0'
3232
f.ref 'refs/heads/master'
3333
f.mutable true
34-
end
34+
end
3535

3636
Factory.define(:remote_git_version, class: GitVersion) do |f|
3737
f.git_repository { Factory(:remote_repository) }

test/factories/workflows.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,18 @@
169169
f.association :content_blob, factory: :spaces_ro_crate
170170
f.workflow_class { WorkflowClass.find_by_title('Jupyter Notebook') || Factory(:jupyter_workflow_class) }
171171
end
172+
173+
Factory.define(:remote_git_workflow, class: Workflow) do |f|
174+
f.title 'Concat two files'
175+
f.with_project_contributor
176+
f.workflow_class { WorkflowClass.find_by_key('galaxy') || Factory(:galaxy_workflow_class) }
177+
f.git_version_attributes {
178+
repo = Factory(:remote_repository)
179+
{ git_repository_id: repo.id,
180+
ref: 'refs/heads/main',
181+
commit: 'b6312caabe582d156dd351fab98ce78356c4b74c',
182+
main_workflow_path: 'concat_two_files.ga',
183+
diagram_path: 'diagram.png',
184+
}
185+
}
186+
end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Basic galaxy workflow
2+
# Branches: main, add-license-1
3+
# Tags: v0.01
4+
# Files on branch "main":
5+
concat_two_files.ga
6+
diagram.png
7+
LICENSE
8+
README.md
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Basic galaxy workflow with abstract CWL
2+
# Branches: master
3+
# Files on branch "main":
4+
Concat_two_files.cwl
5+
concat_two_files.ga
6+
diagram.png

test/functional/ga4gh/trs/v2/tool_versions_controller_test.rb

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,43 @@ class ToolVersionsControllerTest < ActionController::TestCase
220220
r = JSON.parse(@response.body)
221221
assert_equal [], r
222222
end
223+
224+
# Git
225+
226+
test 'should list tool version files for correct descriptor on git workflow' do
227+
workflow = Factory(:remote_git_workflow, policy: Factory(:public_policy))
228+
229+
get :files, params: { id: workflow.id, version_id: 1, type: 'GALAXY' }
230+
231+
assert_response :success
232+
r = JSON.parse(@response.body)
233+
assert_equal 6, r.length
234+
galaxy = r.detect { |f| f['path'] == 'concat_two_files.ga' }
235+
diagram = r.detect { |f| f['path'] == 'diagram.png' }
236+
assert galaxy
237+
assert_equal 'PRIMARY_DESCRIPTOR', galaxy['file_type']
238+
assert diagram
239+
assert_equal 'OTHER', diagram['file_type']
240+
end
241+
242+
test 'should get main workflow as primary descriptor on git workflow' do
243+
workflow = Factory(:remote_git_workflow, policy: Factory(:public_policy))
244+
245+
get :descriptor, params: { id: workflow.id, version_id: 1, type: 'GALAXY' }
246+
247+
assert_response :success
248+
assert @response.body.include?('a_galaxy_workflow')
249+
end
250+
251+
test 'should get descriptor file via relative path on git workflow' do
252+
workflow = Factory(:remote_git_workflow, policy: Factory(:public_policy))
253+
254+
get :descriptor, params: { id: workflow.id, version_id: 1, type: 'GALAXY', relative_path: 'concat_two_files.ga' }
255+
256+
assert_response :success
257+
assert_equal 'application/json; charset=utf-8', @response.headers['Content-Type']
258+
assert @response.body.include?('a_galaxy_workflow')
259+
end
223260
end
224261
end
225262
end

0 commit comments

Comments
 (0)