-
Notifications
You must be signed in to change notification settings - Fork 427
Expand file tree
/
Copy pathversions_spec.rb
More file actions
102 lines (89 loc) · 3.79 KB
/
Copy pathversions_spec.rb
File metadata and controls
102 lines (89 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# frozen_string_literal: true
require_relative 'spec_helper'
RSpec.describe 'Maven buildpack' do
it 'runs Maven wrapper instead of installing Maven when possible' do
app = Hatchet::Runner.new('simple-http-service')
app.deploy do
expect(clean_output(app.output)).to include('$ ./mvnw')
expect(clean_output(app.output)).to(
include("[BUILDPACK INTEGRATION TEST - MAVEN VERSION] #{SIMPLE_HTTP_SERVICE_MAVEN_WRAPPER_VERSION}")
)
end
end
it 'prioritizes installed Maven over wrapper when maven.version property is present' do
app = Hatchet::Runner.new('simple-http-service')
app.before_deploy do
add_to_system_properties('maven.version', DEFAULT_MAVEN_VERSION)
end
app.deploy do
expect(clean_output(app.output)).not_to include('$ ./mvnw')
expect(clean_output(app.output)).to include("remote: -----> Installing Maven #{DEFAULT_MAVEN_VERSION}...")
expect(clean_output(app.output)).to(
include("[BUILDPACK INTEGRATION TEST - MAVEN VERSION] #{DEFAULT_MAVEN_VERSION}")
)
end
end
it 'prioritizes installed Maven when maven.version property is present, even when the version is unknown' do
app = Hatchet::Runner.new('simple-http-service', allow_failure: true)
app.before_deploy do
add_to_system_properties('maven.version', UNKNOWN_MAVEN_VERSION)
end
app.deploy do
expect(clean_output(app.output)).to include(<<~OUTPUT)
remote: -----> Installing Maven #{UNKNOWN_MAVEN_VERSION}...
remote:
remote: ! ERROR: You have defined an unsupported Maven version in the system.properties file.
remote: !
remote: ! The default supported version is #{DEFAULT_MAVEN_VERSION}
remote:
remote: ! Push rejected, failed to compile Java app.
OUTPUT
end
end
it 'installs the default Maven version when no wrapper is present and no version is explicitly configured' do
app = Hatchet::Runner.new('simple-http-service', allow_failure: true)
app.before_deploy do
`rm -r mvnw`
end
app.deploy do
expect(clean_output(app.output)).not_to include('$ ./mvnw')
expect(clean_output(app.output)).to include("remote: -----> Installing Maven #{DEFAULT_MAVEN_VERSION}...")
expect(clean_output(app.output)).to(
include("[BUILDPACK INTEGRATION TEST - MAVEN VERSION] #{DEFAULT_MAVEN_VERSION}")
)
end
end
it 'fails with an error message when the configured Maven version is unknown' do
app = Hatchet::Runner.new('simple-http-service', allow_failure: true)
app.before_deploy do
`rm -f mvnw`
add_to_system_properties('maven.version', UNKNOWN_MAVEN_VERSION)
end
app.deploy do
expect(clean_output(app.output)).to include(<<~OUTPUT)
remote: -----> Installing Maven #{UNKNOWN_MAVEN_VERSION}...
remote:
remote: ! ERROR: You have defined an unsupported Maven version in the system.properties file.
remote: !
remote: ! The default supported version is #{DEFAULT_MAVEN_VERSION}
remote:
remote: ! Push rejected, failed to compile Java app.
OUTPUT
end
end
it 'installs the correct Maven version when explicitly configured' do
app = Hatchet::Runner.new('simple-http-service')
app.before_deploy do
`rm mvnw`
add_to_system_properties('maven.version', '3.9.4')
end
app.deploy do
expect(clean_output(app.output)).not_to include('$ ./mvnw')
expect(clean_output(app.output)).to include('remote: -----> Installing Maven 3.9.4...')
expect(clean_output(app.output)).to include('[BUILDPACK INTEGRATION TEST - MAVEN VERSION] 3.9.4')
end
end
end
DEFAULT_MAVEN_VERSION = '3.9.4'
UNKNOWN_MAVEN_VERSION = '1.0.0-unknown-version'
SIMPLE_HTTP_SERVICE_MAVEN_WRAPPER_VERSION = '3.6.3'