homebrew-core/Formula/dgraph.rb

79 lines
2.1 KiB
Ruby

class Dgraph < Formula
desc "Fast, Distributed Graph DB"
homepage "https://dgraph.io"
url "https://github.com/dgraph-io/dgraph/archive/v20.07.0.tar.gz"
sha256 "46b5deac70d09343644ce10fa69fc313589c7474d974ec720c24504883dd65c1"
# Source code in this repository is variously licensed under the Apache Public License 2.0 (APL)
# and the Dgraph Community License (DCL). A copy of each license can be found in the licenses directory.
license "Apache-2.0"
head "https://github.com/dgraph-io/dgraph.git"
livecheck do
url :stable
regex(/^v?(\d+(?:\.\d+)+)$/i)
end
bottle do
cellar :any_skip_relocation
sha256 "eb57d3ff53372468f23d277e0bf0a39d147a2c7a1b0882d32f53c9200d8721f5" => :catalina
sha256 "0358f83ea5a545ef452ced5cb123c34d6880bc848ad2006e042801c19e2f0770" => :mojave
sha256 "290e72cb04f180ed4a11850d2aff0a42d5cde1c780191f0a920ae7578ef64e5a" => :high_sierra
end
depends_on "go" => :build
def install
ENV["GOBIN"] = bin
system "make", "oss_install"
end
test do
fork do
exec bin/"dgraph", "zero"
end
fork do
exec bin/"dgraph", "alpha", "--lru_mb=1024"
end
sleep 10
(testpath/"mutate.json").write <<~EOS
{
"set": [
{
"name": "Karthic",
"age": 28,
"follows": {
"name": "Jessica",
"age": 31
}
}
]
}
EOS
(testpath/"query.graphql").write <<~EOS
{
people(func: has(name), orderasc: name) {
name
age
}
}
EOS
system "curl", "-s", "-H", "Content-Type: application/json",
"-XPOST", "--data-binary", "@#{testpath}/mutate.json",
"http://localhost:8080/mutate?commitNow=true"
command = %W[
curl -s -H "Content-Type: application/graphql+-"
-XPOST --data-binary @#{testpath}/query.graphql
http://localhost:8080/query
]
response = JSON.parse(shell_output(command.join(" ")))
expected = [{ "name" => "Jessica", "age" => 31 }, { "name" => "Karthic", "age" => 28 }]
assert_equal response["data"]["people"], expected
ensure
system "pkill", "-9", "-f", "dgraph"
end
end