forked from Homebrew/homebrew-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapache-brooklyn-cli.rb
56 lines (50 loc) · 1.91 KB
/
apache-brooklyn-cli.rb
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
class ApacheBrooklynCli < Formula
desc "Apache Brooklyn command-line interface"
homepage "https://brooklyn.apache.org"
url "https://github.com/apache/brooklyn-client/archive/rel/apache-brooklyn-0.12.0.tar.gz"
sha256 "1d0975252a41f1fd65268b915778d4974a0eff2a8a315280e3dedc0e39ef486f"
bottle do
cellar :any_skip_relocation
sha256 "bc1c638f30c4036519eff703b605de6d22313970e585576bcf16183381f59247" => :high_sierra
sha256 "b2ad53984d4e98ef3d37622ff0ff9dd987f4ecc2614e251f3df60de13d96b6c2" => :sierra
sha256 "39f56956e1ed81dfae64401caa333f910b70312d6e45950ac5e2bb3c0db59cfe" => :el_capitan
end
depends_on "glide" => :build
depends_on "go" => :build
def install
ENV["XC_OS"] = "darwin"
ENV["XC_ARCH"] = "amd64"
ENV["GOPATH"] = buildpath
ENV["GOBIN"] = bin
ENV["GLIDE_HOME"] = HOMEBREW_CACHE/"glide_home/#{name}"
(buildpath/"src/github.com/apache/brooklyn-client").install "cli"
cd "src/github.com/apache/brooklyn-client/cli" do
system "glide", "install"
system "go", "install", ".../br"
prefix.install_metafiles
end
end
test do
require "socket"
server = TCPServer.new("localhost", 0)
pid_mock_brooklyn = fork do
loop do
socket = server.accept
response = '{"version":"1.2.3","buildSha1":"dummysha","buildBranch":"1.2.3"}'
socket.print "HTTP/1.1 200 OK\r\n" \
"Content-Type: application/json\r\n" \
"Content-Length: #{response.bytesize}\r\n" \
"Connection: close\r\n"
socket.print "\r\n"
socket.print response
socket.close
end
end
begin
mock_brooklyn_url = "http://localhost:#{server.addr[1]}"
assert_equal "Connected to Brooklyn version 1.2.3 at #{mock_brooklyn_url}\n", shell_output("#{bin}/br login #{mock_brooklyn_url} username password")
ensure
Process.kill("KILL", pid_mock_brooklyn)
end
end
end