@@ -40,4 +40,36 @@ class BenchmarkRunTest < ActiveSupport::TestCase
40
40
BenchmarkRun . latest_commit_benchmark_run ( benchmark_type , benchmark_result_type )
41
41
)
42
42
end
43
+
44
+ test '.fetch_release_benchmark_runs' do
45
+ script_url = 'https://raw.githubusercontent.com/org/repo/master/script/bench.rb'
46
+
47
+ ruby = create ( :repo , name : 'ruby' )
48
+ rails = create ( :repo , name : 'rails' )
49
+
50
+ ruby_release = create ( :release , repo : ruby , version : '2.6.2' )
51
+ rails_release = create ( :release , repo : rails , version : '6.0.0' )
52
+
53
+ ruby_benchmark_type = create ( :benchmark_type , category : 'discourse_home' , repo : ruby , script_url : script_url )
54
+ rails_benchmark_type = create ( :benchmark_type , category : 'discourse_home' , repo : rails , script_url : script_url )
55
+
56
+ benchmark_result_type = create ( :benchmark_result_type )
57
+ ruby_benchmark_run = create ( :release_benchmark_run ,
58
+ benchmark_result_type : benchmark_result_type ,
59
+ benchmark_type : ruby_benchmark_type ,
60
+ initiator : ruby_release
61
+ )
62
+ rails_benchmark_run = create ( :release_benchmark_run ,
63
+ benchmark_result_type : benchmark_result_type ,
64
+ benchmark_type : rails_benchmark_type ,
65
+ initiator : rails_release
66
+ )
67
+ ruby_result = BenchmarkRun . fetch_release_benchmark_runs ( ruby_benchmark_type , benchmark_result_type )
68
+ assert_equal ( 1 , ruby_result . size )
69
+ assert_equal ( ruby_benchmark_run . id , ruby_result . first . id )
70
+
71
+ rails_result = BenchmarkRun . fetch_release_benchmark_runs ( rails_benchmark_type , benchmark_result_type )
72
+ assert_equal ( 1 , rails_result . size )
73
+ assert_equal ( rails_benchmark_run . id , rails_result . first . id )
74
+ end
43
75
end
0 commit comments