Skip to content

Commit

Permalink
Add test for non-repudiation-app option parser
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanobaghino-da committed Mar 11, 2021
1 parent f3495a2 commit af4c13a
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
12 changes: 12 additions & 0 deletions runtime-components/non-repudiation-app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
load(
"//bazel_tools:scala.bzl",
"da_scala_binary",
"da_scala_test",
)

da_scala_binary(
Expand Down Expand Up @@ -35,3 +36,14 @@ da_scala_binary(
"@maven//:io_grpc_grpc_netty",
],
)

da_scala_test(
name = "test",
srcs = glob(["src/test/scala/**/*.scala"]),
scala_deps = [
"@maven//:com_github_scopt_scopt",
],
deps = [
":non-repudiation-app",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

package com.daml.nonrepudiation.app

import java.net.InetSocketAddress

import org.scalatest.OptionValues
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

final class OptionParserSpec extends AnyFlatSpec with Matchers with OptionValues {

behavior of "OptionParser"

it should "parse the expected options" in {

val options = Array(
"--ledger-host",
"168.10.67.4",
"--ledger-port",
"7890",
"--proxy-host",
"168.10.67.5",
"--proxy-port",
"7891",
"--api-host",
"168.10.67.6",
"--api-port",
"7892",
"--jdbc",
"url=jdbc:postgresql:nr,user=psql,password=secret",
"--database-max-pool-size",
"30",
)

val expectedConfiguration =
Configuration(
participantAddress = new InetSocketAddress("168.10.67.4", 7890),
proxyAddress = new InetSocketAddress("168.10.67.5", 7891),
apiAddress = new InetSocketAddress("168.10.67.6", 7892),
apiShutdownTimeout = Configuration.Default.apiShutdownTimeout,
databaseJdbcUrl = "jdbc:postgresql:nr",
databaseJdbcUsername = "psql",
databaseJdbcPassword = "secret",
databaseMaxPoolSize = 30,
metricsReportingPeriod = Configuration.Default.metricsReportingPeriod,
)

OptionParser.parse(options, Configuration.Default).value shouldBe expectedConfiguration

}

}

0 comments on commit af4c13a

Please sign in to comment.